ErlVolton
ErlVolton

Reputation: 6784

What does the getResponseMessage() method of HttpURLConnection return?

I am writing an android application which uses HttpURLConnection for downloads. I am wondering what the getResponseMessage() method returns. If I make a successful (200 OK) request, will it return the same thing as the data given by getInputStream() ? What will it return if my request receives a non-200 status code?

Upvotes: 6

Views: 7062

Answers (1)

An SO User
An SO User

Reputation: 24998

It will return an HTTP response message. Have a look here http://en.m.wikipedia.org/wiki/List_of_HTTP_status_codes
Like the famous 404 Not Found.

The docs clearly say:
Returns the response message returned by the remote HTTP

It doesn't return the data you want to retrieve. It gives you information about your connection.

Upvotes: 6

Related Questions