Class: TingYun::Http::CurbRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/http/curb_wrappers.rb

Constant Summary collapse

CURB =
'Curb'.freeze
LHOST =
'host'.freeze
UHOST =
'Host'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(curlobj) ⇒ CurbRequest

Returns a new instance of CurbRequest.



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

def initialize( curlobj )
  @curlobj = curlobj
end

Instance Method Details

#[](key) ⇒ Object



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

def []( key )
  @curlobj.headers[ key ]
end

#[]=(key, value) ⇒ Object



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

def []=( key, value )
  @curlobj.headers[ key ] = value
end

#fromObject



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

def from
  "curb%2Fhttp"
end

#hostObject



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

def host
  host_from_header || self.uri.host
end

#host_from_headerObject



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

def host_from_header
  self[LHOST] || self[UHOST]
end

#methodObject



33
34
35
# File 'lib/ting_yun/http/curb_wrappers.rb', line 33

def method
  @curlobj._ty_http_verb
end

#typeObject



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

def type
  CURB
end

#uriObject



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

def uri
  @uri ||= TingYun::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@curlobj.url)
end