lib/buckaruby/request.rb in buckaruby-1.0.1 vs lib/buckaruby/request.rb in buckaruby-1.0.2
- old
+ new
@@ -39,14 +39,19 @@
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
end
raw_response = http.post(uri.request_uri, post_data(params))
+
+ unless raw_response.is_a?(Net::HTTPSuccess)
+ raise InvalidResponseException, raw_response
+ end
+
return raw_response.body
# Try to catch some common exceptions Net::HTTP might raise
- rescue Errno::ETIMEDOUT, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, IOError, SocketError,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::OpenTimeout, Net::ProtocolError, Net::ReadTimeout,
- OpenSSL::SSL::SSLError => ex
+ rescue Errno::ETIMEDOUT, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
+ IOError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::OpenTimeout,
+ Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError => ex
raise ConnectionException, ex
end
def build_request_data(options)
params = { brq_websitekey: @options[:website] }