class HTTPX::Response

  1. lib/httpx/response.rb
Superclass: Object

Classes and Modules

  1. HTTPX::Response::Body

Attributes

body [R]
headers [R]
status [R]
version [R]

Public Class methods

new (request, status, version, headers)
[show source]
   # File lib/httpx/response.rb
24 def initialize(request, status, version, headers)
25   @request = request
26   @options = request.options
27   @version = version
28   @status = Integer(status)
29   @headers = @options.headers_class.new(headers)
30   @body = @options.response_body_class.new(self, threshold_size: @options.body_threshold_size,
31                                                  window_size: @options.window_size)
32 end

Public Instance methods

<< (data)
[show source]
   # File lib/httpx/response.rb
38 def <<(data)
39   @body.write(data)
40 end
bodyless? ()
[show source]
   # File lib/httpx/response.rb
42 def bodyless?
43   @request.verb == :head ||
44     no_data?
45 end
complete? ()
[show source]
   # File lib/httpx/response.rb
51 def complete?
52   bodyless? || (@request.verb == :connect && @status == 200)
53 end
content_type ()
[show source]
   # File lib/httpx/response.rb
47 def content_type
48   ContentType.parse(@headers["content-type"])
49 end
inspect ()
[show source]
   # File lib/httpx/response.rb
55 def inspect
56   "#<Response:#{object_id} @status=#{@status} @headers=#{@headers}>"
57 end
merge_headers (h)
[show source]
   # File lib/httpx/response.rb
34 def merge_headers(h)
35   @headers = @headers.merge(h)
36 end
raise_for_status ()
[show source]
   # File lib/httpx/response.rb
59 def raise_for_status
60   return if @status < 400
61 
62   raise HTTPError, self
63 end