Class: Typhoeus::Response::Header Private
- Inherits:
-
Hash
- Object
- Hash
- Typhoeus::Response::Header
- Defined in:
- lib/typhoeus/response/header.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This class represents the response header. It can be accessed like a hash. Values can be strings (normal case) or arrays of strings (for duplicates headers)
Instance Method Summary collapse
- #[](key) ⇒ Object private
-
#initialize(raw) ⇒ Header
constructor
private
Create a new header.
-
#parse ⇒ Object
private
Parses the raw header.
Constructor Details
#initialize(raw) ⇒ Header
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new header.
19 20 21 22 23 24 |
# File 'lib/typhoeus/response/header.rb', line 19 def initialize(raw) super({}) @raw = raw @sanitized = {} parse end |
Instance Method Details
#[](key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/typhoeus/response/header.rb', line 26 def [](key) fetch(key) { @sanitized[key.to_s.downcase] } end |
#parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parses the raw header.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/typhoeus/response/header.rb', line 34 def parse case @raw when Hash raw.each do |k, v| process_pair(k, v) end when String raw.split(/\r?\n(?!\s)/).each do |header| header.strip! next if header.empty? || header.start_with?( 'HTTP/' ) process_line(header) end end end |