Class: HTTPcap::Headers
- Inherits:
-
Object
- Object
- HTTPcap::Headers
- Extended by:
- Forwardable
- Defined in:
- lib/httpcap/headers.rb
Overview
http headers for http-parser
Constant Summary collapse
- TYPE_FIELD =
:f- TYPE_VALUE =
:v
Instance Method Summary collapse
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
- #stream(type, value) ⇒ Object
- #stream_complete ⇒ Object
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
17 18 19 20 21 |
# File 'lib/httpcap/headers.rb', line 17 def initialize @content = {} @bucket = [] @state = nil end |
Instance Method Details
#stream(type, value) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/httpcap/headers.rb', line 23 def stream(type, value) if @state == type @bucket[-1] += value else @bucket << value end @state = type end |
#stream_complete ⇒ Object
32 33 34 35 |
# File 'lib/httpcap/headers.rb', line 32 def stream_complete @content.merge!(@bucket.each_slice(2).to_a.select { |a| a.size == 2 }.to_h) @bucket.clear end |