Class: Quicsilver::Protocol::RequestEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/quicsilver/protocol/request_encoder.rb

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, scheme: "https", authority: "localhost:4433", headers: {}, body: nil, encoder: Qpack::Encoder.new) ⇒ RequestEncoder

Returns a new instance of RequestEncoder.



6
7
8
9
10
11
12
13
14
# File 'lib/quicsilver/protocol/request_encoder.rb', line 6

def initialize(method:, path:, scheme: "https", authority: "localhost:4433", headers: {}, body: nil, encoder: Qpack::Encoder.new)
  @method = method.upcase
  @path = path
  @scheme = scheme
  @authority = authority
  @headers = headers
  @body = body
  @encoder = encoder
end

Instance Method Details

#encodeObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/quicsilver/protocol/request_encoder.rb', line 16

def encode
  frames = "".b
  frames << build_frame(FRAME_HEADERS, @encoder.encode(all_headers))

  if @body && !@body.empty?
    body_data = @body.is_a?(String) ? @body : @body.join
    frames << build_frame(FRAME_DATA, body_data)
  end

  frames
end