404 response not read (Android)

Monkey Forums/Monkey Bug Reports/404 response not read (Android)

secondgear(Posted 2016) [#1]
Some REST APIs return error messages with 404 status. In this case Java throws an IOException in httprequest.android.java line 60:
InputStream in=_con.getInputStream();

and as a result the response text is not passed to Monkey code. I would suggest the following fix:
InputStream in;
try {
	in =_con.getInputStream();
} catch (IOException ex) {
	in = _con.getErrorStream();
	if (in == null) {
		_con.disconnect();
		return;
	}
}


Edit: there was a problem with my original post - the app would crash if there was no network connection. I should've checked if in is null in the catch block. Fixed now.