Skip to content

Commit

Permalink
Merge pull request #50 from rafaeliga/request-errors-fix
Browse files Browse the repository at this point in the history
Fix crash on requests that returns an error
  • Loading branch information
andrewhavens authored Dec 15, 2016
2 parents d8739a0 + d0f1df2 commit 82f1e31
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 82f1e31

Please sign in to comment.