Yesterday was the first time in years a remote #REST #API server required me to send the #ContentLength #requestHeader. The #HTTP component I was using, #HttpURLConnection by Sun, outright refused to set it.

I looked up the HTTP RFC: yes, it is called Content-Length, and yes, it's a count of 16-bit characters. And it can be used only if neither streaming nor chunking the contents. My code met those requirements.

What was going on?
#YesterdayILearned that the new #java.net.http #HttpClient (introduced in Java 11) no longer gives access to the server's HTTP status message, nor its error stream. The older #HttpURLConnection did do that.

The new client lets us set request headers more easily. However, I found no way to lift the restriction on the Content-Length header. The older version let us switch that off using either a command-line switch or explicit code.

The new client supports HTTP2. So that's good.