Return-Path: Delivered-To: apmail-jakarta-httpclient-dev-archive@www.apache.org Received: (qmail 12939 invoked from network); 8 Feb 2005 22:29:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Feb 2005 22:29:21 -0000 Received: (qmail 7442 invoked by uid 500); 8 Feb 2005 22:29:20 -0000 Delivered-To: apmail-jakarta-httpclient-dev-archive@jakarta.apache.org Received: (qmail 7426 invoked by uid 500); 8 Feb 2005 22:29:20 -0000 Mailing-List: contact httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "HttpClient Project" Reply-To: "HttpClient Project" Delivered-To: mailing list httpclient-dev@jakarta.apache.org Received: (qmail 7402 invoked by uid 99); 8 Feb 2005 22:29:20 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from mail11.bluewin.ch (HELO mail11.bluewin.ch) (195.186.18.61) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 08 Feb 2005 14:29:19 -0800 Received: from xbox.localdomain (62.203.207.126) by mail11.bluewin.ch (Bluewin AG 7.0.035) id 41DE975A003A7A08 for httpclient-dev@jakarta.apache.org; Tue, 8 Feb 2005 22:29:16 +0000 Received: from 192.168.0.2 (unknown [192.168.0.2]) by xbox.localdomain (Postfix) with ESMTP id 9A933B6ECA for ; Tue, 8 Feb 2005 23:29:16 +0100 (CET) Subject: Re: Error Receiving Session Cookie From: Oleg Kalnichevski To: HttpClient Project In-Reply-To: <20050208203210.11077.qmail@web30207.mail.mud.yahoo.com> References: <20050208203210.11077.qmail@web30207.mail.mud.yahoo.com> Content-Type: text/plain Date: Tue, 08 Feb 2005 23:29:15 +0100 Message-Id: <1107901755.5011.69.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Mayhew, Try masquerading HttpClient as a popular browser of your choice (IE for instance) and see if that makes any difference GetMethod authget = new GetMethod("/"); authget.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); Oleg On Tue, 2005-02-08 at 12:32 -0800, Mayhew Seavey wrote: > I am trying to use HTTPClient to browse the site > "www.allmusic.com", and it seems to be having trouble > getting a session cookie when it first enters the > site. > > I've used IE and Mozilla, first clearing all the > site-related cookies, and then going to the site, > confirming that on loading of the home page, a single > cookie is created. > > Then I used the HTTPClient to load the site with the > code below, and it doesn't register any cookies having > been loaded. > > I need to have this cookie in order to go to other > sections of the site. The code and wire trace are > below. > > Any help would be greatly appreciated! > > Thanks, > Mayhew > > ==================== > > HttpClient client = new HttpClient(); > > client.getHostConfiguration().setHost(LOGON_SITE, > LOGON_PORT, "http"); > > client.getState().setCookiePolicy(CookiePolicy.NETSCAPE_DRAFT); > // 'developer.java.sun.com' has cookie > compliance problems > // Their session cookie's domain attribute is > in violation of the RFC2109 > // We have to resort to using compatibility > cookie policy > > GetMethod authget = new GetMethod("/"); > > client.executeMethod(authget); > System.out.println("Login form get: " + > authget.getStatusLine().toString()); > // release any connection resources used by > the method > authget.releaseConnection(); > // See if we got any cookies > CookieSpec cookiespec = > CookiePolicy.getDefaultSpec(); > Cookie[] initcookies = cookiespec.match( > LOGON_SITE, LOGON_PORT, "/", false, > client.getState().getCookies()); > System.out.println("Initial set of cookies:"); > > if ((initcookies == null) || > (initcookies.length == 0)) { > System.out.println("None"); > } else { > for (int i = 0; i < initcookies.length; > i++) { > System.out.println("- " + > initcookies[i].toString()); > } > } > > ======================= > > Wire trace: > > 2005/02/08 15:11:41:734 EST [DEBUG] HttpMethodBase - > Execute loop try 1 > 2005/02/08 15:11:41:750 EST [DEBUG] header - >> "GET / > HTTP/1.1[\r][\n]" > 2005/02/08 15:11:41:750 EST [DEBUG] HttpMethodBase - > Adding Host request header > 2005/02/08 15:11:41:750 EST [DEBUG] header - >> > "User-Agent: Jakarta Commons-HttpClient/2.0.2[\r][\n]" > 2005/02/08 15:11:41:750 EST [DEBUG] header - >> "Host: > www.allmusic.com[\r][\n]" > 2005/02/08 15:11:41:750 EST [DEBUG] header - >> > "[\r][\n]" > Login form get: HTTP/1.0 200 OK > 2005/02/08 15:11:42:140 EST [DEBUG] header - << > "HTTP/1.0 200 OK[\r][\n]" > 2005/02/08 15:11:42:140 EST [DEBUG] header - << > "Content-Type: text/html[\r][\n]" > 2005/02/08 15:11:42:140 EST [DEBUG] header - << > "Content-Length: 22834[\r][\n]" > 2005/02/08 15:11:42:140 EST [DEBUG] header - << > "Content: [\r][\n]" > 2005/02/08 15:11:42:296 EST [DEBUG] HttpMethodBase - > Resorting to protocol version default close connection > policy > 2005/02/08 15:11:42:296 EST [DEBUG] HttpMethodBase - > Should close connection, using HTTP/1.0. > > > > > __________________________________ > Do you Yahoo!? > The all-new My Yahoo! - Get yours free! > http://my.yahoo.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org