Class: Http2::BaseRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/http2/base_request.rb

Direct Known Subclasses

GetRequest, PostMultipartRequest, PostRequest

Constant Summary collapse

VALID_ARGUMENTS_POST =
[:post, :url, :default_headers, :headers, :json, :method, :cookies, :on_content, :content_type].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http2, args) ⇒ BaseRequest

Returns a new instance of BaseRequest.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/http2/base_request.rb', line 6

def initialize(http2, args)
  @http2 = http2
  @args = http2.parse_args(args)
  @debug = http2.debug
  @nl = http2.nl

  @args.each_key do |key|
    raise "Invalid key: '#{key}'." unless VALID_ARGUMENTS_POST.include?(key)
  end

  @conn = @http2.connection
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



2
3
4
# File 'lib/http2/base_request.rb', line 2

def args
  @args
end

#debugObject (readonly)

Returns the value of attribute debug.



2
3
4
# File 'lib/http2/base_request.rb', line 2

def debug
  @debug
end

#http2Object (readonly)

Returns the value of attribute http2.



2
3
4
# File 'lib/http2/base_request.rb', line 2

def http2
  @http2
end

Instance Method Details

#pathObject



19
20
21
# File 'lib/http2/base_request.rb', line 19

def path
  @args.fetch(:url)
end