Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

module Requests
class Error < StandardError
attr_reader :response
attr_reader :response, :status, :headers, :body

def initialize(response)
super(response.message)

@response = response
@status = Integer(response.code)
@headers = response.to_hash
@body = response.body
end
end

Expand Down
2 changes: 1 addition & 1 deletion tests/proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
assert_equal ['application/json'], r.headers['content-type']
assert(r.json['args'] && r.json['args']['foo'] == 'bar')

assert_equal ["1.1 vegur, 1.1 0.0.0.0:#{port}"], r.headers['via']
assert_equal ["1.1 0.0.0.0:#{port}"], r.headers['via']

proxy.shutdown
end
4 changes: 4 additions & 0 deletions tests/requests_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
Requests.post('http://httpbin.org/something')
rescue Requests::Error => e
assert_equal Net::HTTPNotFound, e.response.class

assert_equal Hash, e.headers.class
assert_equal String, e.body.class
assert_equal 404, e.status
end
end

Expand Down