I'm trying to fetch a URL (in this case 4sq.com) and it tries to set
an invalid cookie. Java balks and prints an ugly warning to stderr. It
still works so I can ignore it, but I'd rather get rid of the thing.

Mar 21, 2010 6:09:25 AM org.apache.commons.httpclient.HttpMethodBase
processResponseHeaders
WARNING: Cookie rejected: "$Version=0; _bit=4ba5b815-002d9-0699f-
baa08fa8; $Path=/; $Domain=.4sq.com". Illegal domain attribute ".
4sq.com". Domain of origin: "4sq.com"

I've tried three methods - the java.net buffered input method, the
'low-level' com.google.appengine.api.urlfetch method, and even using
apache's HttpClient directly. It seems that appengine doesn't want me
getting around its abstraction of HttpClient because I get permission
errors on opening the socket. The java.net and URLFetch methods don't
allow me to overwrite the cookie handling policies so they both throw
the warning.

Here's a function with the three methods - two of them commented out.

[code]
public void getURL(URL url) throws Exception {
        String content = "";
        String regex = "";

        System.out.println("Getting url: "+url+" domain: "+url.getHost()
+" path: "+url.getPath());

        BufferedReader reader = new BufferedReader(new
InputStreamReader(url.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
                content += line;
        }
        reader.close();


        /*
        URLFetchService fetcher;
        HTTPRequest request;
        HTTPResponse response;
        request = new HTTPRequest(url);
        fetcher = URLFetchServiceFactory.getURLFetchService();
        response = fetcher.fetch(request);
        content = new String(response.getContent());
        */

        /*
        HttpMethod method;
        HttpClient client;
        client = new HttpClient();
        method = new GetMethod(url.toString());
        method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
        client.executeMethod(method);
        content = method.getResponseBodyAsString();
        method.releaseConnection();
        */

        //now do something with content

    }
[/code]

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to