hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Domain attribute ".msn.com" violates RFC 2109: host minus domain may not contain any dots
Date Fri, 11 Feb 2005 21:04:04 GMT
On Fri, 2005-02-11 at 09:24 -0800, Gamas Sugiarto wrote:
> Hi Oleg,
> 
> I found a logic error in my code.
> Toward the end of my code I accidentally reset HttpClientParams to the 
> HttpClient, that is why RFC2109Spec is being called again instead of my 
> MyCookieSpec.
> 
> Anyway, I just removed that reset code and it works fine right now.
> 
> I am still curious though if Hotmail website is setting MalformedCookie 
> format, why is regular web browser does not complain?

So called regular web browser tend to be extremely lenient about
standard compliance in order to be compatible with thousands of badly
written CGI scripts out there. Both IE & Mozilla pretty much accept any
garbage thrown at them

Oleg

> 
> Anyway thank you for taking the time to look into my code :)
> 
> Gamas Sugiarto
> 
> Oleg Kalnichevski wrote:
> 
> >On Thu, Feb 10, 2005 at 03:16:12PM -0800, Gamas Sugiarto wrote:
> >  
> >
> >>Hi,
> >>
> >>I am trying to do hotmail account login but everytime I try, I got this 
> >>      
> >>
> >>         MalformedCookieException
> >>
> >>saying that
> >>
> >>         Domain attribute ".msn.com" violates RFC 2109: host minus 
> >>domain may not contain any dots
> >>
> >>I am tempted to go to 
> >>org.apache.commons.httpclient.cookie.RFC2109Spec.java to alter the src 
> >>code for my purposes, but hoping there might be a better way to do this.
> >>
> >>    
> >>
> >
> >Please don't. If you do not mind building HttpClient from source, rather
> >run your application in debugger and see why RFC2109 is still being
> >called.
> >
> >I have cursorily examined your code and found nothing with it. It
> >_should_ work. I'll review HttpClient code responsible for picking a
> >cookie policy just in case it got unintentionally broken
> >
> >Cheers,
> >
> >Oleg
> >
> >
> >  
> >
> >>I tried creating my own custom (MyCookieSpec) that extends from 
> >>CookieSpecBase, register that cookie to CookiePolicy and use it in my 
> >>HttpClient, but for some weird reason during runtime it still goes to 
> >>RFC2109Spec.validate(..) which will again throws the above exception.
> >>
> >>Any suggestion to better approach this problem?
> >>
> >>The following is my code:
> >>       InputStream result = null;
> >>       if(client == null) {
> >>           client = new HttpClient();
> >>       }
> >>      
> >>       // *************** 1st URL **************************************
> >>       client.getHostConfiguration().setHost("login.passport.net", 80, 
> >>"http");
> >>       CookiePolicy.registerCookieSpec("mycookie", MyCookieSpec.class);
> >>       client.getParams().setCookiePolicy("mycookie");
> >>      
> >>       HttpClientParams clientParams = client.getParams();
> >>       clientParams.setParameter("http.protocol.single-cookie-header", 
> >>new Boolean(true));
> >>       client.setParams(clientParams);
> >>              
> >>       GetMethod getMethod1 = new GetMethod("/uilogin.srf");
> >>       getMethod1.setRequestHeader("User-Agent", "Mozilla/5.0 (X11; U; 
> >>Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
> >>       getMethod1.setRequestHeader("Keep-Alive", "300");
> >>       getMethod1.setFollowRedirects(true);
> >>       client.executeMethod(getMethod1);
> >>       getMethod1.releaseConnection();
> >>      
> >>      
> >>       // *************** 2nd URL ************************************
> >>       client.getHostConfiguration().setHost("login.passport.net", 80, 
> >>"http");
> >>       GetMethod getMethod2 = new GetMethod("/uilogin.srf");
> >>       getMethod2.setRequestHeader("User-Agent", "Mozilla/5.0 (X11; U; 
> >>Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
> >>       getMethod2.setRequestHeader("Keep-Alive", "300");
> >>       client.executeMethod(getMethod2);   
> >>       getMethod2.releaseConnection();
> >>      
> >>       // *************** 3rd URL **************************************
> >>       client.getHostConfiguration().setHost("loginnet.passport.com", 
> >>443, "https");
> >>       GetMethod getMethod3 = new GetMethod("/ppsecure/post.srf");
> >>       getMethod3.setRequestHeader("User-Agent", "Mozilla/5.0 (X11; U; 
> >>Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
> >>       getMethod3.setRequestHeader("Keep-Alive", "300");       
> >>     
> >>       NameValuePair sec   = new NameValuePair("sec", "rem");
> >>       NameValuePair userid   = new NameValuePair("login", sLogin);
> >>       NameValuePair password = new NameValuePair("passwd", sPassword);
> >>       NameValuePair domain = new NameValuePair("domain", "hotmail.com");
> >>       NameValuePair lc = new NameValuePair("lc", "1033");
> >>       NameValuePair id = new NameValuePair("id", "10");
> >>       NameValuePair tw = new NameValuePair("tw", "20");
> >>       NameValuePair cbid = new NameValuePair("cbid", "10");
> >>       NameValuePair da = new NameValuePair("da", "passport.com");
> >>       NameValuePair mspp_shared =new 
> >>NameValuePair("mspp_shared","1");     
> >>       NameValuePair paddingValue = new NameValuePair("padding", 
> >>"xxxxxxxxxxxxxxxx".substring(0, 16-sPassword.length()));
> >>             
> >>       getMethod3.setQueryString(new NameValuePair[] {sec, userid, 
> >>password,lc,id,tw,da,paddingValue});      
> >>       int status = client.executeMethod(getMethod3);          
> >>       getMethod3.releaseConnection();
> >>      
> >>       // *************** 4th URL **************************************
> >>       client.getHostConfiguration().setHost("hotmail.msn.com", 80, 
> >>"http");       
> >>       GetMethod getMethod4 = new GetMethod("/cgi-bin/addresses");       
> >>       NameValuePair fti = new NameValuePair("fti", "yes");
> >>       NameValuePair lang = new NameValuePair("lang", "EN");
> >>     
> >>       getMethod4.setRequestHeader("User-Agent", "Mozilla/5.0 (X11; U; 
> >>Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
> >>       getMethod4.setRequestHeader("Keep-Alive", "300");
> >>      
> >>       getMethod4.setQueryString(new NameValuePair[]{fti,lang});
> >>       getMethod4.setFollowRedirects(true);
> >>       HttpClientParams params = new HttpClientParams();
> >>       params.setIntParameter(HttpClientParams.MAX_REDIRECTS, 1000);
> >>       
> >>params.setLongParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 
> >>60000);      
> >>       client.setParams(params);
> >>     
> >>       client.executeMethod(getMethod4);
> >>       getMethod4.releaseConnection();
> >>
> >>       //*************** 5th URL **************************************
> >>       GetMethod getMethod5 = new GetMethod("/cgi-bin/addresses");
> >>       getMethod5.setRequestHeader("User-Agent", "Mozilla/5.0 (X11; U; 
> >>Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
> >>       getMethod5.setRequestHeader("Keep-Alive", "300");       
> >>       getMethod5.setQueryString(new NameValuePair[]{fti,lang});
> >>       getMethod5.setFollowRedirects(true);
> >>       client.executeMethod(getMethod5);
> >>      
> >>       myprint("Redirect: " + getMethod5.getStatusLine().toString());
> >>       result = getMethod5.getResponseBodyAsStream();
> >>       BufferedReader reader = new BufferedReader(new 
> >>InputStreamReader(result));
> >>       StringBuffer sbResult = new StringBuffer();
> >>      
> >>       int r = 0;
> >>       while((r = reader.read()) != -1) {
> >>           sbResult.append((char)r);
> >>       }
> >>       reader.close();
> >>       rawContactData = sbResult.toString();
> >>       myprint("addressBook=\n"+rawContactData);    
> >>       getMethod5.releaseConnection();
> >>
> >>Thank you very much.
> >>
> >>Gamas Sugiarto
> >>      
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >  
> >
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message