I found a work-around. Instead of using HttpURLConnection, I open a socket
connection directly to www.google.com:80 and was able to get the search
results (in HTML data). It seems like Android's HttpURLConnection adds
request header to make my life miserable.

However, when I tried to print the request headers

        Map map = http.getRequestProperties();
        System.out.println(map);

It shows an empty collection.

What's happening? Does Google really doesn't want me to search? Please, I
beg you, let me search ........

On Fri, Mar 6, 2009 at 12:06 AM, Mattaku Betsujin <
mattaku.betsu...@gmail.com> wrote:

> I want to do a google search, so I open an HttpURLConnection() to
> www.google.com. However, I am getting an error:
>
> url = http://www.google.com/search?&q=123
>
> java.io.FileNotFoundException: http://www.google.com/search?&q=123
>    at
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1040)
>    at com.nubinews.reader.URLFetcher.readHttp(URLFetcher.java:535)
>    at
> com.nubinews.reader.URLFetcher$ConnectionThread.getText2Internal(URLFetcher.java:417)
>    at
> com.nubinews.reader.URLFetcher$ConnectionThread.getText2InThread(URLFetcher.java:365)
>    at
> com.nubinews.reader.URLFetcher$ConnectionThread.processCommands(URLFetcher.java:341)
>    at
> com.nubinews.reader.URLFetcher$ConnectionThread.run(URLFetcher.java:323)
>
> and the response headers are:
>
> HEADER: null = HTTP/1.1 403 Forbidden
> HEADER: content-type = text/html; charset=UTF-8
> HEADER: date = Fri, 06 Mar 2009 08:02:53 GMT
> HEADER: server = gws
> HEADER: cache-control = private, x-gzip-ok=""
> HEADER: transfer-encoding = chunked
>
> What should I do?
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to