HipByte / Flow

Cross-platform libraries for RubyMotion
BSD 2-Clause "Simplified" License
141 stars 29 forks source link

if empty body, iOS crashed #63

Closed joseph-montanez closed 7 years ago

joseph-montanez commented 7 years ago

When a get request with the content type of JSON has an empty body the application would crash. This should not happen, the developer it is forced to remove the content type which doesn't make sense. While on Android it would work fine. This at least brings consistency in that regard.

Here is the code that would crash an iOS application


    session = Net.build('https://httpbin.org') do
      header(:content_type, :json)
    end

    reachability = Net.reachable?('httpbin.org') { |reachable|
      if reachable
        session.get('/ip') { |response|
          puts 'success'
        }
      else
        puts 'host is down!'
      end
    }

    reachability.stop
lrz commented 7 years ago

Thanks a lot for the contribution!