class TingYun::Http::ExconHTTPRequest

Constants

COLON
EXCON
LHOST
UHOST

Attributes

method[R]

Public Class Methods

new(datum) click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 38
def initialize(datum)
  @datum = datum

  @method = @datum[:method].to_s.upcase
  @scheme = @datum[:scheme]
  @port   = @datum[:port]
  @path   = @datum[:path]
end

Public Instance Methods

[](key) click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 74
def [](key)
  @datum[:headers][key]
end
[]=(key, value) click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 78
def []=(key, value)
  @datum[:headers] ||= {}
  @datum[:headers][key] = value
end
from() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 51
def from
  "excon http"
end
host() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 62
def host
  host_from_header || @datum[:host]
end
host_from_header() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 55
def host_from_header
  headers = @datum[:headers]
  if hostname = (headers[LHOST] || headers[UHOST])
    hostname.split(COLON).first
  end
end
path() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 70
def path
  @path
end
port() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 66
def port
  @port
end
type() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 47
def type
  EXCON
end
uri() click to toggle source
# File lib/ting_yun/http/excon_wrappers.rb, line 83
def uri
  URI.parse("#{@scheme}://#{host}:#{@port}#{@path}")
end