Class: NetHttp2::Request::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/net-http2/request/base.rb

Direct Known Subclasses

Delete, Get, Post, Put

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, uri, path, body, headers, options = {}) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
16
17
# File 'lib/net-http2/request/base.rb', line 10

def initialize(method, uri, path, body, headers, options={})
  @method  = method
  @uri     = uri
  @path    = path
  @body    = body
  @headers = headers
  @timeout = options[:timeout] || DEFAULT_TIMEOUT
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/net-http2/request/base.rb', line 8

def body
  @body
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/net-http2/request/base.rb', line 8

def path
  @path
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



8
9
10
# File 'lib/net-http2/request/base.rb', line 8

def timeout
  @timeout
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/net-http2/request/base.rb', line 8

def uri
  @uri
end

Instance Method Details

#headersObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/net-http2/request/base.rb', line 19

def headers
  @headers.merge!({
    ':scheme'        => @uri.scheme,
    ':method'        => @method,
    ':path'          => @path,
  })

  @headers.merge!('host' => @uri.host) unless @headers['host']
  @headers.merge!('content-length' => @body.bytesize.to_s) if @body

  @headers
end