I know I am missing something obvious, but creating a connection with the following code on
java 1.4.2 the content length is always 0 even though it is explicitly set.
URL url = new URL("http://localhost:" + port);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String testData="this is a
test!";
String LEN_HDR="Content-Length";
String TYPE_HDR="Content-Type";
conn.setRequestProperty(TYPE_HDR,"text/html");
conn.setRequestProperty(LEN_HDR,String.valueOf(testData.length()));
conn.setRequestProperty("TEST"+LEN_HDR,String.valueOf(testData.length()));
conn.setDoOutput(true);
conn.setRequestMethod("POST");
OutputStream os = conn.getOutputStream();
PrintStream ps = new java.io.PrintStream(os);
ps.println("test");
ps.flush();
here are the headers are received on the server
POST / HTTP/1.1
Content-Type: text/html
Content-Length: 0
TESTContent-Length: 15
User-Agent: Java/1.4.2
Host: localhost:91
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Thanks in advance for any help
Jeff