Class: HTTP::Headers
Instance Method Summary collapse
- #[](header_name) ⇒ Object
- #each ⇒ Object
-
#initialize(native_response) ⇒ Headers
constructor
A new instance of Headers.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(native_response) ⇒ Headers
Returns a new instance of Headers.
29 30 31 |
# File 'lib/http_client/jruby/response.rb', line 29 def initialize(native_response) @native_response = native_response end |
Instance Method Details
#[](header_name) ⇒ Object
33 34 35 |
# File 'lib/http_client/jruby/response.rb', line 33 def [](header_name) @native_response.get_headers(header_name).map{|h| h.get_value}.join(", ") end |
#each ⇒ Object
49 50 51 52 53 |
# File 'lib/http_client/jruby/response.rb', line 49 def each @native_response.header_iterator.each do |h| yield h.get_name, h.get_value end end |
#to_hash ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/http_client/jruby/response.rb', line 41 def to_hash hash = {} each do |name, value| hash[name] = hash[name] ? hash[name] + ", #{value}" : value end hash end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/http_client/jruby/response.rb', line 37 def to_s @native_response.get_all_headers.map(&:to_s).join("\n") end |