Class: HTTPX::Parser::HTTP1

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/parser/http1.rb

Constant Summary collapse

VERSIONS =
%w[1.0 1.1].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(observer) ⇒ HTTP1

Returns a new instance of HTTP1.



12
13
14
15
16
17
# File 'lib/httpx/parser/http1.rb', line 12

def initialize(observer)
  @observer = observer
  @state = :idle
  @buffer = "".b
  @headers = {}
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/httpx/parser/http1.rb', line 10

def headers
  @headers
end

#http_versionObject (readonly)

Returns the value of attribute http_version.



10
11
12
# File 'lib/httpx/parser/http1.rb', line 10

def http_version
  @http_version
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



10
11
12
# File 'lib/httpx/parser/http1.rb', line 10

def status_code
  @status_code
end

Instance Method Details

#<<(chunk) ⇒ Object



19
20
21
22
# File 'lib/httpx/parser/http1.rb', line 19

def <<(chunk)
  @buffer << chunk
  parse
end

#reset!Object



24
25
26
27
28
29
# File 'lib/httpx/parser/http1.rb', line 24

def reset!
  @state = :idle
  @headers.clear
  @content_length = nil
  @_has_trailers = nil
end

#upgrade?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/httpx/parser/http1.rb', line 31

def upgrade?
  @upgrade
end

#upgrade_dataObject



35
36
37
# File 'lib/httpx/parser/http1.rb', line 35

def upgrade_data
  @buffer
end