Class: Dialed::HTTP::Response
- Inherits:
-
Object
- Object
- Dialed::HTTP::Response
show all
- Defined in:
- lib/dialed/http/response.rb
Defined Under Namespace
Classes: Body, EveryBody, JsonBody
Instance Method Summary
collapse
Constructor Details
#initialize(internal_response) ⇒ Response
Returns a new instance of Response.
19
20
21
22
23
|
# File 'lib/dialed/http/response.rb', line 19
def initialize(internal_response)
@internal_response = internal_response
@notifier = Async::Notification.new
buffer!
end
|
Instance Method Details
#body ⇒ Object
25
26
27
|
# File 'lib/dialed/http/response.rb', line 25
def body
@body ||= body_klass.new(internal_response.body)
end
|
#body_klass ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/dialed/http/response.rb', line 29
def body_klass
case
in { 'content-type': 'application/json' }
JsonBody
else
EveryBody
end
end
|
#buffer! ⇒ Object
38
39
40
|
# File 'lib/dialed/http/response.rb', line 38
def buffer!
@internal_response.buffered!
end
|
50
51
52
53
54
55
|
# File 'lib/dialed/http/response.rb', line 50
def
@headers ||= internal_response
&.
&.to_h
&.transform_keys(&:to_sym)
end
|
#http11? ⇒ Boolean
46
47
48
|
# File 'lib/dialed/http/response.rb', line 46
def http11?
internal_response.version == 'HTTP/1.1'
end
|
#http2? ⇒ Boolean
42
43
44
|
# File 'lib/dialed/http/response.rb', line 42
def http2?
internal_response.version == 'HTTP/2'
end
|