Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 92198 invoked from network); 11 Jul 2006 15:00:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2006 15:00:40 -0000 Received: (qmail 38385 invoked by uid 500); 11 Jul 2006 15:00:38 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 38369 invoked by uid 500); 11 Jul 2006 15:00:38 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 38358 invoked by uid 99); 11 Jul 2006 15:00:38 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 08:00:38 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [85.90.206.104] (HELO office.redwerk.com) (85.90.206.104) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 08:00:36 -0700 Received: from bofh by office.redwerk.com with local (Exim 4.62 (FreeBSD)) (envelope-from ) id 1G0JiU-0004pY-57 for httpclient-user@jakarta.apache.org; Tue, 11 Jul 2006 18:00:02 +0300 Date: Tue, 11 Jul 2006 18:00:02 +0300 From: Eugeny N Dzhurinsky To: httpclient-user@jakarta.apache.org Subject: multiple "location" headers are getting concatenated? Message-ID: <20060711150002.GA18421@office.redwerk.com> Mail-Followup-To: httpclient-user@jakarta.apache.org Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.11 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hello, I facing strange problem with HttpClient For some reason if there are more than 1 Location header in response, all headers are collected into single string, for instance - /madeline/?GCID=C1000x047&AID=10280172&PID=1453275, /madeline I used this test: import junit.framework.Assert; import junit.framework.TestCase; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.params.HttpClientParams; import org.apache.commons.httpclient.params.HttpMethodParams; import java.io.IOException; public class HTTPClientTest extends TestCase { HttpClient client; HttpMethod method; protected void setUp() throws Exception { client = new HttpClient(); String url = "http://www.allaboardtoys.com/madeline/default.asp?GCID=C1000x047&AID=10280172&PID=1453275"; URI uri = new URI(url, url.indexOf('%') != -1); method = new GetMethod(); method.setURI(uri); HttpMethodParams params = method.getParams(); params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); params.setParameter(HttpClientParams.USER_AGENT, "Mozilla/4.0" + "(compatible; MSIE 6.0; Windows NT 5.1;)"); method.setFollowRedirects(true); } public void testResultcode() { try { client.executeMethod(method); Assert.assertEquals(HttpStatus.SC_OK, method.getStatusCode()); } catch (HttpException e) { e.printStackTrace(System.out); } catch (IOException e) { e.printStackTrace(System.out); } } } With tcpflow i found: request was --------------------------------------------------------------------------- GET /madeline/default.asp?GCID=C1000x047&AID=10280172&PID=1453275 HTTP/1.1 User-Agent: Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1;) Host: www.allaboardtoys.com --------------------------------------------------------------------------- and response --------------------------------------------------------------------------- HTTP/1.1 302 Object moved Server: Microsoft-IIS/5.0 Date: Tue, 11 Jul 2006 14:52:28 GMT X-Powered-By: ASP.NET P3P: policyref="http://www.allaboardtoys.com/w3c/p3p.xml" Pragma: no-cache cache-control: no-store Cache-Control: no-cache, must-revalidate Location: http://www.allaboardtoys.com/madeline/?GCID=C1000x047&AID=10280172&PID=1453275 Location: /madeline Content-Length: 130 Content-Type: text/html Expires: Mon, 10 Jul 2006 14:52:28 GMT Set-Cookie: ShopperManager%2F=sts=nwc45&ShopperManager%2F=C08BA8AEFED14F27BF4EF3FF1CE0CD85; expires=Wed, 26-Jul-2006 14:52:28 GMT; domain=allaboardtoys.com; path=/ Set-Cookie: ASPSESSIONIDCATQCDDQ=JLAADADBKEKJBHKKFALPEMHH; path=/ Cache-control: no-cache Object moved

Object Moved

This object may be found here. --------------------------------------------------------------------------- then next request --------------------------------------------------------------------------- GET /madeline/?GCID=C1000x047&AID=10280172&PID=1453275, /madeline HTTP/1.1 User-Agent: Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1;) Host: www.allaboardtoys.com Cookie: ShopperManager%2F=sts=nwc45&ShopperManager%2F=C08BA8AEFED14F27BF4EF3FF1CE0CD85 Cookie: ASPSESSIONIDCATQCDDQ=JLAADADBKEKJBHKKFALPEMHH --------------------------------------------------------------------------- and finally --------------------------------------------------------------------------- HTTP/1.1 400 Bad Request Server: Microsoft-IIS/5.0 Date: Tue, 11 Jul 2006 14:52:28 GMT Content-Type: text/html Content-Length: 87 ErrorThe parameter is incorrect. --------------------------------------------------------------------------- As you can see, instead of http://www.allaboardtoys.com/madeline HttpClient used /madeline/?GCID=C1000x047&AID=10280172&PID=1453275, /madeline which is wrong. I tried to handle redirects manually, but contents of header "location" are http://www.allaboardtoys.com/madeline/?GCID=C1000x047&AID=10280172&PID=1453275, /madeline Is it correct to split it by comma or I can get list of headers manually somehow? -- Eugene N Dzhurinsky --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org