Class: Readme::HttpResponse
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Readme::HttpResponse
show all
- Includes:
- ContentTypeHelper
- Defined in:
- lib/readme/http_response.rb
Constant Summary
ContentTypeHelper::JSON_MIME_TYPES
Class Method Summary
collapse
Instance Method Summary
collapse
#json?
Class Method Details
.from_parts(status, headers, body) ⇒ Object
9
10
11
|
# File 'lib/readme/http_response.rb', line 9
def self.from_parts(status, , body)
new(Rack::Response.new(body, status, ))
end
|
Instance Method Details
#body ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/readme/http_response.rb', line 13
def body
if raw_body.respond_to?(:rewind)
raw_body.rewind
content = raw_body.each.sum('')
raw_body.rewind
content
else
raw_body.each.sum('')
end
end
|
#content_length ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/readme/http_response.rb', line 25
def content_length
if empty_body_status?
0
elsif !['Content-Length']
body.bytesize
else
['Content-Length'].to_i
end
end
|