Skip to content
Draft
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
10 changes: 10 additions & 0 deletions lib/protocol/http1/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def close
end

def write_request(authority, method, path, version, headers)
sending_request if respond_to?(:sending_request)

@stream.write("#{method} #{path} #{version}\r\n")
@stream.write("host: #{authority}\r\n")

Expand Down Expand Up @@ -157,8 +159,12 @@ def read_line
end

def read_request
waiting_for_request if respond_to?(:waiting_for_request)

return unless line = read_line?

receiving_request if respond_to?(:receiving_request)

if match = line.match(REQUEST_LINE)
_, method, path, version = *match
else
Expand All @@ -177,12 +183,16 @@ def read_request
end

def read_response(method)
waiting_for_response if respond_to?(:waiting_for_response)

version, status, reason = read_line.split(/\s+/, 3)

status = Integer(status)

headers = read_headers

received_response if respond_to?(:received_response)

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

body = read_response_body(method, status, headers)
Expand Down