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 14:52:57 GMT
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


Mime
View raw message