Sha256: 164e33821f4194bc6a75adbf77139df78079929be853223b9e0155768c9c6bf4

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.

require_relative '../request'

module Async
	module HTTP
		module Protocol
			module HTTP1
				class Request < Protocol::Request
					def self.read(connection)
						if parts = connection.read_request
							self.new(connection, *parts)
						end
					end
					
					UPGRADE = 'upgrade'
					
					def initialize(connection, authority, method, path, version, headers, body)
						@connection = connection
						
						# HTTP/1 requests with an upgrade header (which can contain zero or more values) are extracted into the protocol field of the request, and we expect a response to select one of those protocols with a status code of 101 Switching Protocols.
						protocol = headers.delete('upgrade')
						
						super(nil, authority, method, path, version, headers, body, protocol)
					end
					
					def connection
						@connection
					end
					
					def hijack?
						true
					end
					
					def hijack!
						@connection.hijack!
					end
					
					def write_interim_response(response)
						@connection.write_interim_response(response.version, response.status, response.headers)
					end
				end
			end
		end
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
async-http-0.72.0 lib/async/http/protocol/http1/request.rb
async-http-0.71.0 lib/async/http/protocol/http1/request.rb
async-http-0.70.0 lib/async/http/protocol/http1/request.rb
async-http-0.69.0 lib/async/http/protocol/http1/request.rb
async-http-0.68.0 lib/async/http/protocol/http1/request.rb
async-http-0.67.1 lib/async/http/protocol/http1/request.rb
async-http-0.67.0 lib/async/http/protocol/http1/request.rb
async-http-0.66.2 lib/async/http/protocol/http1/request.rb
async-http-0.66.1 lib/async/http/protocol/http1/request.rb
async-http-0.66.0 lib/async/http/protocol/http1/request.rb
async-http-0.65.1 lib/async/http/protocol/http1/request.rb
async-http-0.65.0 lib/async/http/protocol/http1/request.rb