Class: NOMS::Command::UserAgent::Response::HTTPClient

Inherits:
NOMS::Command::UserAgent::Response show all
Defined in:
lib/noms/command/useragent/response/httpclient.rb

Instance Attribute Summary

Attributes inherited from NOMS::Command::UserAgent::Response

#auth_hash, #cache_control, #date, #etag, #expires, #from_cache, #last_modified, #original_date

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from NOMS::Command::UserAgent::Response

#age, #cacheable?, #cacheable_copy, #cached!, #content_encoding, #current?, from_cache, #from_cache?, from_json, #get_expires, #get_header_time, #header_params, #to_cache, #to_hash, #to_json

Methods inherited from Base

#default_logger

Constructor Details

#initialize(httpresponse, opts = {}) ⇒ HTTPClient

Returns a new instance of HTTPClient.



25
26
27
28
29
# File 'lib/noms/command/useragent/response/httpclient.rb', line 25

def initialize(httpresponse, opts={})
    super
    @log = opts[:logger] || default_logger
    @response = httpresponse
end

Instance Method Details

#bodyObject



31
32
33
# File 'lib/noms/command/useragent/response/httpclient.rb', line 31

def body
    @response.content
end

#content_typeObject



55
56
57
# File 'lib/noms/command/useragent/response/httpclient.rb', line 55

def content_type
    @response.contenttype
end

#header(hdr = nil) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/noms/command/useragent/response/httpclient.rb', line 39

def header(hdr=nil)
    if hdr.nil?
        @response.headers
    else
        @response.header[hdr.downcase].first
    end
end

#statusObject



47
48
49
# File 'lib/noms/command/useragent/response/httpclient.rb', line 47

def status
    @response.status.to_i unless @response.status.nil?
end

#statusTextObject



51
52
53
# File 'lib/noms/command/useragent/response/httpclient.rb', line 51

def statusText
    @response.status.to_s + ' ' + @response.reason unless @response.status.nil?
end

#success?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/noms/command/useragent/response/httpclient.rb', line 35

def success?
    @response.ok?
end