Class: Biryani::HTTP::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/biryani/http/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, uri, fields, content) ⇒ Request

Returns a new instance of Request.

Parameters:

  • method (String)
  • uri (URI)
  • fields (Hash<String, Array<String>>)
  • content (String)


10
11
12
13
14
15
# File 'lib/biryani/http/request.rb', line 10

def initialize(method, uri, fields, content)
  @method = method
  @uri = uri
  @fields = fields
  @content = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/biryani/http/request.rb', line 4

def content
  @content
end

#fieldsObject

Returns the value of attribute fields.



4
5
6
# File 'lib/biryani/http/request.rb', line 4

def fields
  @fields
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/biryani/http/request.rb', line 4

def method
  @method
end

#uriObject

Returns the value of attribute uri.



4
5
6
# File 'lib/biryani/http/request.rb', line 4

def uri
  @uri
end

Instance Method Details

#trailersArray<String>?

Returns:

  • (Array<String>, nil)


18
19
20
21
22
# File 'lib/biryani/http/request.rb', line 18

def trailers
  # https://datatracker.ietf.org/doc/html/rfc9110#section-6.6.2-4
  keys = (@fields['trailer'] || []).flat_map { |x| x.split(',').map(&:strip) }
  @fields.slice(*keys)
end