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
27 def initialize(request, status, version, headers)
28   @request = request
29   @options = request.options
30   @version = version
31   @status = Integer(status)
32   @headers = @options.headers_class.new(headers)
33   @body = @options.response_body_class.new(self, @options)
34   @finished = complete?
35 end

Public Instance methods

<<(data)
[show source]
   # File lib/httpx/response.rb
41 def <<(data)
42   @body.write(data)
43 end
bodyless?()
[show source]
   # File lib/httpx/response.rb
58 def bodyless?
59   @request.verb == :head ||
60     no_data?
61 end
complete?()
[show source]
   # File lib/httpx/response.rb
63 def complete?
64   bodyless? || (@request.verb == :connect && @status == 200)
65 end
content_type()
[show source]
   # File lib/httpx/response.rb
45 def content_type
46   @content_type ||= ContentType.new(@headers["content-type"])
47 end
error()

:nocov:

[show source]
   # File lib/httpx/response.rb
77 def error
78   return if @status < 400
79 
80   HTTPError.new(self)
81 end
finish!()
[show source]
   # File lib/httpx/response.rb
53 def finish!
54   @finished = true
55   @headers.freeze
56 end
finished?()
[show source]
   # File lib/httpx/response.rb
49 def finished?
50   @finished
51 end
form()
[show source]
   # File lib/httpx/response.rb
93 def form
94   decode("form")
95 end
inspect()

:nocov:

[show source]
   # File lib/httpx/response.rb
68 def inspect
69   "#<Response:#{object_id} " \
70     "HTTP/#{version} " \
71     "@status=#{@status} " \
72     "@headers=#{@headers} " \
73     "@body=#{@body.bytesize}>"
74 end
json(*args)
[show source]
   # File lib/httpx/response.rb
89 def json(*args)
90   decode("json", *args)
91 end
merge_headers(h)
[show source]
   # File lib/httpx/response.rb
37 def merge_headers(h)
38   @headers = @headers.merge(h)
39 end
raise_for_status()
[show source]
   # File lib/httpx/response.rb
83 def raise_for_status
84   return self unless (err = error)
85 
86   raise err
87 end
xml()
[show source]
   # File lib/httpx/response.rb
97 def xml
98   decode("xml")
99 end