Class: TingYun::Http::HttpClientRequest

Inherits:
AbstractRequest show all
Defined in:
lib/ting_yun/http/http_client_request.rb

Constant Summary

Constants inherited from AbstractRequest

AbstractRequest::ERROR_MESSAGE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy, *args, &block) ⇒ HttpClientRequest

Returns a new instance of HttpClientRequest.



7
8
9
10
11
# File 'lib/ting_yun/http/http_client_request.rb', line 7

def initialize(proxy, *args, &block)
  @method, @uri, @query, @body, @header = args
  @proxy = proxy
  @block = block
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



5
6
7
# File 'lib/ting_yun/http/http_client_request.rb', line 5

def header
  @header
end

#methodObject (readonly)

Returns the value of attribute method.



5
6
7
# File 'lib/ting_yun/http/http_client_request.rb', line 5

def method
  @method
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/ting_yun/http/http_client_request.rb', line 21

def [](key)
  @header[key]
end

#[]=(key, value) ⇒ Object



25
26
27
# File 'lib/ting_yun/http/http_client_request.rb', line 25

def []=(key, value)
  @header[key] = value
end

#argsObject



34
35
36
# File 'lib/ting_yun/http/http_client_request.rb', line 34

def args
  return @method, @uri, @query, @body, @header
end

#fromObject



17
18
19
# File 'lib/ting_yun/http/http_client_request.rb', line 17

def from
  "http_client%2Fhttp"
end

#typeObject



13
14
15
# File 'lib/ting_yun/http/http_client_request.rb', line 13

def type
  'HTTPClient'
end

#uriObject



29
30
31
32
# File 'lib/ting_yun/http/http_client_request.rb', line 29

def uri
  return @uri if @uri.scheme && @uri.host && @uri.port
  URI("#{@proxy.scheme.downcase}://#{@proxy.host}:#{@proxy.port}#{@uri}")
end