Class: Typhoeus::Response::Header Private

Inherits:
Hash
  • Object
show all
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.

Since:

  • 0.5.0

Instance Method Summary collapse

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.

Examples:

Create new header.

Header.new(raw)

Parameters:

  • raw (String)

    The raw header.

Since:

  • 0.5.0



16
17
18
19
20
21
# File 'lib/typhoeus/response/header.rb', line 16

def initialize(raw)
  @raw = raw
  @sanitized = {}
  parse
  set_default_proc_on(self, lambda { |h, k| @sanitized[k.to_s.downcase] })
end

Instance Method Details

#parseObject

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.

Examples:

Parse header.

header.parse

Since:

  • 0.5.0



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/typhoeus/response/header.rb', line 27

def parse
  case @raw
  when Hash
    raw.each do |k, v|
      process_pair(k, v)
    end
  when String
    raw.lines.each do |header|
      next if header.empty? || header =~ /^HTTP\/1.[01]/
      process_line(header)
    end
  end
end