Point taken. :-)
Steve Johnson, Software Engineer, [EMAIL PROTECTED] direct 720.564.6532 www.mercury.com <http://www.mercury.com/> <http://www.mercury.com/> <http://www.mercury.com/> -----Original Message----- From: Steve Johnson [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 08, 2005 4:01 PM To: 'HttpClient Project' Subject: RE: Error Receiving Session Cookie Hmmmm, The culprit: http://www.allmusic.com/cg/__utm.js <http://www.allmusic.com/cg/__utm.js> cookie mania? It appears that this page creates cookies in your browser session. What is wrong with people? Then magically, GET /__utm.gif?utmn=2833708675&utmsr=1280x1024&utmsa=1280x994&utmsc=32-bit&utmbs=1136x623&utmul=en-us&utmje=1&utmc e=1&utmtz=-0700&utmjv=1.3&utmr=-&utmp=/ HTTP/1.1 Accept: */* Referer: http://www.allmusic.com/ <http://www.allmusic.com/> Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322) Host: www.allmusic.com Connection: Keep-Alive Cookie: __utma=215752519.2833708675.1107901895.1107901895.1107901895.1; __utmb=215752519; __utmc=215752519 Steve Johnson, Software Engineer, [EMAIL PROTECTED] direct 720.564.6532 www.mercury.com www.mercury.com -----Original Message----- From: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] Sent: Tuesday, February 08, 2005 3:29 PM To: HttpClient Project Subject: Re: Error Receiving Session Cookie 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 <http://my.yahoo.com> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
