commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian <...@bashford.net>
Subject [httpclient] HTTP Post with 0 content-length
Date Thu, 06 Feb 2003 14:17:03 GMT
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

Mime
View raw message