signing the http1 parser as well

This commit is contained in:
HoneyryderChuck 2020-10-26 15:06:31 +00:00
parent 96eaf1ef05
commit 805096b721
2 changed files with 52 additions and 3 deletions

View File

@ -9,10 +9,9 @@ module HTTPX
attr_reader :status_code, :http_version, :headers
def initialize(observer, header_separator: ":")
def initialize(observer)
@observer = observer
@state = :idle
@header_separator = header_separator
@buffer = "".b
@headers = {}
end
@ -94,7 +93,7 @@ module HTTPX
end
return
end
separator_index = line.index(@header_separator)
separator_index = line.index(":")
raise Error, "wrong header format" unless separator_index
key = line[0..separator_index - 1]

50
sig/parser/http1.rbs Normal file
View File

@ -0,0 +1,50 @@
module HTTPX
module Parser
type parsed_headers = Hash[String, Array[String]]
interface _HTTP1Events
def on_start: () -> void
def on_headers: (parsed_headers) -> void
def on_trailers: (parsed_headers) -> void
def on_data: (String) -> void
def on_complete: () -> void
end
class HTTP1
VERSIONS: Array[String]
def <<: (String chunk) -> void
def headers: () -> parsed_headers
def http_version: () -> Array[1 | 0]
def reset!: () -> void
def status_code: () -> Integer
def upgrade?: () -> bool
def upgrade_data: () -> String
private
def initialize: (_HTTP1Events observer) -> untyped
def nextstate: (Symbol state) -> void
def no_more_data?: () -> bool
def parse: () -> void
def parse_data: () -> void
def parse_headers: () -> void
def parse_headline: () -> void
def prepare_data: (parsed_headers headers) -> void
end
end
end