バイト配列を HTTP サーバーに転送する Java コードがあります。
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary="
+ myBoundary);
connection.setRequestProperty("Content-Length", 1024);
このコードを使用して、サイズが 1024 より大きいバイト配列を転送しました。うまくいきました。しかし、実際の HTTP メッセージ ( Wiresharkでキャプチャ) は、 Content-Length の値が 1024 ではなく実際のサイズであることを示しています。なぜでしょうか?
HTTP 仕様で検索しましたが、ヒントが見つかりませんでした。Transfer-Encoding または Transfer-coding は使用しませんでした。