Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using HttpClient latest version (4.x). And right now I'm trying to do A GET Request. I just posting a Get request.

This is my Code;

public class Poster {

    static boolean routing1 = true, routing2 = true;
    static int counter1 = 0, counter2 = 0;
    DefaultHttpClient oHtp = null;
    HttpGet oHGet = null;
    HttpResponse oHRes = null;


    private void test(String fullAddress) throws Exception {
        oHtp = new DefaultHttpClient();
        oHGet = new HttpGet(fullAddress);

        HttpResponse response = oHtp.execute(oHGet);
        System.out.print(response.getStatusLine());

        HttpEntity entity = response.getEntity();
        if (entity != null) {
            entity = new BufferedHttpEntity(entity);
            //  System.out.println(EntityUtils.toString(entity));
            System.out.print(" entity is retrieved... ");
        }


        oHtp.getConnectionManager().shutdown();
    }
}

I just execute it nicely. First is

new Poster().test("http://123.xl.co.id/profile.php");

and second is

 new Poster().test("http://goklik.co.id/");

ya, And Only the Second one.... I got this The error message;

Sep 18, 2011 10:11:30 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Cookie rejected: "[version: 0][name: CookiePst][value: 0149=xwGHF7HYDHLHQ84Isp/eSy9vu+Xq6cT12wxg1A==][domain: .mcore.com][path: /][expiry: Sun Sep 18 10:38:59 ICT 2011]". Illegal domain attribute "mcore.com". Domain of origin: "goklik.co.id"

I realized that the Cookie is involved here. But I don't understand what the Warning means. And I also don't know how to solve it (Cookie not being rejected). Hope there is a bit of light to clear my mind from you guys.... :D

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
733 views
Welcome To Ask or Share your Answers For Others

1 Answer

Maybe it's too late, but I had the same problem and I've found something that helped me work it out, just set the Cookie Policy to Browser Compability:

httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY,
        CookiePolicy.BROWSER_COMPATIBILITY);

Here are the possible values:

The cookie policy provides corresponding cookie management interfrace for a given type or version of cookie.

RFC 2109 specification is used per default. Other supported specification can be chosen when appropriate or set default when desired

The following specifications are provided:

  • BROWSER_COMPATIBILITY: compatible with the common cookie management practices (even if they are not 100% standards compliant)
  • NETSCAPE: Netscape cookie draft compliant
  • RFC_2109: RFC2109 compliant (default)
  • IGNORE_COOKIES: do not automcatically process cookies

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...