Class: Dialed::HTTP::Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, path, *args, **options) ⇒ Request



6
7
8
9
10
11
# File 'lib/dialed/http/request.rb', line 6

def initialize(verb, path, *args, **options)
  @verb = verb
  @path = path
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#verbObject (readonly)

Returns the value of attribute verb.



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

def verb
  @verb
end

Instance Method Details

#call(connection) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dialed/http/request.rb', line 13

def call(connection)
  # protocol_request = Protocol::HTTP::Request[
  #   verb,
  #   path,
  #   *args,
  #   version: connection.version,
  #   headers: options[:headers],
  #   method: verb.upcase,
  #   authority: connection.authority,
  #   scheme:    connection.scheme,
  # ]
  protocol_request = Protocol::HTTP::Request.new.tap do |r|
    r.path = path
    r.method = verb.upcase
    r.headers = options[:headers] if options[:headers]
    r.version = connection.version
    r.authority = connection.authority
    r.scheme = connection.scheme
    r.body = options[:body]
    r.protocol = options[:protocol] if options[:protocol]
  end

  protocol_request.call(connection)
end