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



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

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

#[]=(key, value) ⇒ Object



32
33
34
# File 'lib/ting_yun/http/http_client_request.rb', line 32

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

#argsObject



45
46
47
# File 'lib/ting_yun/http/http_client_request.rb', line 45

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
  "HttpClient"
end

#hostObject



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

def host
  @uri.host || @proxy.host
end

#pathObject



41
42
43
# File 'lib/ting_yun/http/http_client_request.rb', line 41

def path
  @uri
end

#portObject



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

def port
  @uri.port || @uri.port
end

#typeObject



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

def type
  @uri.scheme
end

#uriObject



36
37
38
39
# File 'lib/ting_yun/http/http_client_request.rb', line 36

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