diff --git a/flow/net/android/request.rb b/flow/net/android/request.rb index d0f88b4..e71eb18 100644 --- a/flow/net/android/request.rb +++ b/flow/net/android/request.rb @@ -30,7 +30,14 @@ def run(&callback) stream.write(Java::Lang::String.new(body).getBytes("UTF-8")) end - input_reader = Java::Io::InputStreamReader.new(url_connection.getInputStream) + response_code = url_connection.getResponseCode + + if response_code >= 400 + input_reader = Java::Io::InputStreamReader.new(url_connection.getErrorStream) + else + input_reader = Java::Io::InputStreamReader.new(url_connection.getInputStream) + end + input = Java::Io::BufferedReader.new(input_reader) inputLine = "" response = Java::Lang::StringBuffer.new