Melih Akalan
Melih Akalan

Reputation: 61

Http Request doesn't give correct response

I'm trying to make a http request and get the full page as string.

After I got response, I'm trying to find the position of a substring in it.

But I can't find that substring in the response whereas the original web page contains that substring in Google Chrome -> View Source. (Checked in mobile version).

So, my guesses are:

1) Maybe It's not requesting the mobile version of that web page? If it is so, how can I change my user agent to a mobile version? like chrome android?

2) Is it possible that response does not give me the full page? Because, when I try, LogCat isn't showing the full page.

Thanks.

Upvotes: 0

Views: 84

Answers (2)

user3199327
user3199327

Reputation: 11

Try this

1) http://www.intertech.com/Blog/android-defaulthttpclientandroidhttpclient-and-httpparams/ this will help you for changing user agent.

2) for logging try to log your response like Log.d("Reponse is: ", response);

Upvotes: 1

Greg Ennis
Greg Ennis

Reputation: 15381

1) Yes you can set the user agent by creating your client like this:

HttpClient client = AndroidHttpClient.newInstance("MyAppUserAgent/1.0");

2) You would need to post the code, but logcat will not necessarily dump the entire response. There is maximum length per log and text is clipped to that length.

Upvotes: 0

Related Questions