diff --git a/lib/protocol/http1/connection.rb b/lib/protocol/http1/connection.rb index fccd78f..a709468 100644 --- a/lib/protocol/http1/connection.rb +++ b/lib/protocol/http1/connection.rb @@ -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") @@ -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 @@ -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)