Skip to content

Commit

Permalink
Fix crash on requests that returns an error
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeliga committed Oct 14, 2016
1 parent d7d2efc commit 8549d48
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flow/net/android/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8549d48

Please sign in to comment.