You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ian <ia...@bashford.net> on 2003/02/06 15:17:03 UTC
[httpclient] HTTP Post with 0 content-length
Hi all,
I seem to be successfully sending an HTTP Post but with one problem.
The content-length header is set to zero and nothing I do can make it non zero.
A sniffer reveals the data is sent but as the content-length header is zero, the servlet
at the other end treats it as no content !!!
My code looks like this
state = new HttpState();
postMethod = new PostMethod("http://" + URL);
// Loop to add request Headers {
postMethod.addRequestHeader(headerName,headerValue );
}
postMethod.setFollowRedirects(false);
NameValuePair[] nvp = new NameValuePair [numParameters];
// Generate an array of NameValuePairs
postMethod.addParameters(nvp);
// Next line is default but .....
postMethod.setRequestContentLength(PostMethod.CONTENT_LENGTH_AUTO);
// Get Connection from Connection Manager
responseCode = method.execute(state, conn);
// Process response
The servlet receives
Headers
accept:text/*, image/jpeg, image/png, image/*, */*
accept-charset:iso-8859-1, utf-8;q=0.5, *;q=0.5
accept-encoding:x-gzip, gzip, identity
accept-language:en
content-length:0
content-type:application/x-www-form-urlencoded
host:eris2
user-agent:Mozilla/5.0 (compatible; Konqueror/3; Linux)
Parameters
0oc:106
Posted
0 bytes sent
Nothing I do changes the content-length from zero !!
Can anyone help ?
--
Thanks
Ian