Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 10614 invoked from network); 6 Feb 2003 14:12:37 -0000 Received: from rocket.vip.uk.com (62.60.0.97) by daedalus.apache.org with SMTP; 6 Feb 2003 14:12:37 -0000 Received: from modem-114-61-60-62.vip.uk.com ([62.60.61.114] helo=eris) by rocket.vip.uk.com with esmtp (Exim 4.10) id 18gmlY-0003la-00 for commons-user@jakarta.apache.org; Thu, 06 Feb 2003 14:12:36 +0000 Content-Type: text/plain; charset="us-ascii" From: Ian To: commons-user@jakarta.apache.org Subject: [httpclient] HTTP Post with 0 content-length Date: Thu, 6 Feb 2003 14:17:03 +0000 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200302061417.03906.ian@bashford.net> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 ze= ro, the servlet=20 at the other end treats it as no content !!! My code looks like this state =3D new HttpState(); postMethod =3D new PostMethod("http://" + URL); // Loop to add request Headers { postMethod.addRequestHeader(headerName,headerValue ); } postMethod.setFollowRedirects(false); NameValuePair[] nvp =3D 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 =3D 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=3D0.5, *;q=3D0.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 ? --=20 Thanks Ian