Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 427
ErlVolton Avatar asked Jul 25 '14 14:07

ErlVolton


1 Answers

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.

like image 123
An SO User Avatar answered Oct 29 '22 19:10

An SO User