Class: CurlAgent::IO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/curl_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body_str, header_str) ⇒ IO

Returns a new instance of IO.



107
108
109
110
# File 'lib/curl_agent.rb', line 107

def initialize(body_str, header_str)
  super(body_str)
  @header_str = header_str
end

Instance Attribute Details

#base_uriObject

returns a URI which is base of relative URIs in the data. It may differ from the URI supplied by a user because redirection.



105
106
107
# File 'lib/curl_agent.rb', line 105

def base_uri
  @base_uri
end

#statusObject

returns an Array which consists status code and message.



101
102
103
# File 'lib/curl_agent.rb', line 101

def status
  @status
end

Instance Method Details

#metaObject

returns a Hash which represents header fields. The Hash keys are downcased for canonicalization.



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/curl_agent.rb', line 114

def meta
  @meta ||= begin
    arr = @header_str.split(/\r?\n/)
    arr.shift
    arr.inject({}) do |hash, hdr|
      key, val = hdr.split(/:\s+/, 2)
      hash[key.downcase] = val
      hash
    end
  end
end