Class: Low::RequestParser
- Inherits:
-
Object
- Object
- Low::RequestParser
- Includes:
- LowType
- Defined in:
- lib/requests/request_parser.rb
Class Method Summary collapse
- .create_stream(socket: TCPSocket) ⇒ Object
- .parse(stream: IO::Stream::Generic, host: String, port: Integer, version: nil) ⇒ Object
Class Method Details
.create_stream(socket: TCPSocket) ⇒ Object
12 13 14 |
# File 'lib/requests/request_parser.rb', line 12 def create_stream(socket: TCPSocket) -> { IO::Stream::Generic } IO::Stream(socket) end |
.parse(stream: IO::Stream::Generic, host: String, port: Integer, version: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/requests/request_parser.rb', line 16 def parse(stream: IO::Stream::Generic, host: String, port: Integer, version: nil) -> { ::Protocol::HTTP::Request | nil } version ||= Async::HTTP::Protocol::HTTP.default.protocol_for(stream)::VERSION result = parse_request(stream:) return nil unless result method, full_path, = result headers = parse_headers(stream:) body = parse_body(stream:, method:, headers:) ::Protocol::HTTP::Request.new('http', "#{host}:#{port}", method, full_path, version, headers, body) end |