Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/protocol/http1/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def read_line
read_line? or raise EOFError
end

def read_request
def read_request_line
return unless line = read_line?

if match = line.match(REQUEST_LINE)
Expand All @@ -182,6 +182,13 @@ def read_request
raise InvalidRequest, line.inspect
end

return method, path, version
end

def read_request
method, path, version = read_request_line
return unless method

headers = read_headers

@persistent = persistent?(version, method, headers)
Expand All @@ -193,11 +200,17 @@ def read_request
return headers.delete(HOST), method, path, version, headers, body
end

def read_response(method)
def read_status_line
version, status, reason = read_line.split(/\s+/, 3)

status = Integer(status)

return version, status, reason
end

def read_response(method)
version, status, reason = read_status_line

headers = read_headers

@persistent = persistent?(version, method, headers)
Expand Down