Module: HTTPkit::Support::Message
Constant Summary collapse
- TRANSFER_ENCODING =
'Transfer-Encoding'.freeze
- CHUNKED =
'chunked'.freeze
- CONTENT_LENGTH =
'Content-Length'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #body_headers ⇒ Object
- #close ⇒ Object
- #closed(&block) ⇒ Object
- #closed! ⇒ Object
- #closed? ⇒ Boolean
- #reject_closed(reason) ⇒ Object
Class Method Details
.build(parser) ⇒ Object
44 45 46 47 48 |
# File 'lib/httpkit/support/message.rb', line 44 def self.build(parser) = (parser) .close if !.body_included? || !.body_present? end |
Instance Method Details
#body_headers ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/httpkit/support/message.rb', line 30 def body_headers length, encoding = nil, nil if body_present? if body.length_known? length = body.length.to_i else encoding = CHUNKED end end { CONTENT_LENGTH => length, TRANSFER_ENCODING => encoding } end |
#close ⇒ Object
22 23 24 |
# File 'lib/httpkit/support/message.rb', line 22 def close body.closed.fulfill end |
#closed(&block) ⇒ Object
18 19 20 |
# File 'lib/httpkit/support/message.rb', line 18 def closed(&block) body.closed.then(&block) end |
#closed! ⇒ Object
14 15 16 |
# File 'lib/httpkit/support/message.rb', line 14 def closed! body.closed.sync end |
#closed? ⇒ Boolean
10 11 12 |
# File 'lib/httpkit/support/message.rb', line 10 def closed? !body.closed.pending? end |
#reject_closed(reason) ⇒ Object
26 27 28 |
# File 'lib/httpkit/support/message.rb', line 26 def reject_closed(reason) body.closed.reject(reason) end |