Class: Async::HTTP::Protocol::HTTP2::Request::Stream
- Inherits:
-
Stream
- Object
- Protocol::HTTP2::Stream
- Stream
- Async::HTTP::Protocol::HTTP2::Request::Stream
- Defined in:
- lib/async/http/protocol/http2/request.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Attributes inherited from Stream
Instance Method Summary collapse
- #closed(error) ⇒ Object
-
#initialize ⇒ Stream
constructor
A new instance of Stream.
- #receive_initial_headers(headers, end_stream) ⇒ Object
Methods inherited from Stream
#add_header, #finish_output, #prepare_input, #process_data, #process_headers, #receive_trailing_headers, #send_body, #update_local_window, #wait_for_input, #window_updated
Constructor Details
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
23 24 25 |
# File 'lib/async/http/protocol/http2/request.rb', line 23 def request @request end |
Instance Method Details
#closed(error) ⇒ Object
82 83 84 85 86 |
# File 'lib/async/http/protocol/http2/request.rb', line 82 def closed(error) @request = nil super end |
#receive_initial_headers(headers, end_stream) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/async/http/protocol/http2/request.rb', line 25 def receive_initial_headers(headers, end_stream) @headers = ::Protocol::HTTP::Headers.new headers.each do |key, value| if key == SCHEME raise ::Protocol::HTTP2::HeaderError, "Request scheme already specified!" if @request.scheme @request.scheme = value elsif key == AUTHORITY raise ::Protocol::HTTP2::HeaderError, "Request authority already specified!" if @request. @request. = value elsif key == METHOD raise ::Protocol::HTTP2::HeaderError, "Request method already specified!" if @request.method @request.method = value elsif key == PATH raise ::Protocol::HTTP2::HeaderError, "Request path is empty!" if value.empty? raise ::Protocol::HTTP2::HeaderError, "Request path already specified!" if @request.path @request.path = value elsif key == PROTOCOL raise ::Protocol::HTTP2::HeaderError, "Request protocol already specified!" if @request.protocol @request.protocol = value elsif key == CONTENT_LENGTH raise ::Protocol::HTTP2::HeaderError, "Request content length already specified!" if @length @length = Integer(value) elsif key == CONNECTION raise ::Protocol::HTTP2::HeaderError, "Connection header is not allowed!" elsif key.start_with? ":" raise ::Protocol::HTTP2::HeaderError, "Invalid pseudo-header #{key}!" elsif key =~ /[A-Z]/ raise ::Protocol::HTTP2::HeaderError, "Invalid characters in header #{key}!" else add_header(key, value) end end @request.headers = @headers unless @request.valid? raise ::Protocol::HTTP2::HeaderError, "Request is missing required headers!" else # We only construct the input/body if data is coming. unless end_stream @request.body = prepare_input(@length) end # We are ready for processing: @connection.requests.enqueue(@request) end return headers end |