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



15
16
17
18
# File 'lib/typhoeus/response/header.rb', line 15

def initialize(raw)
  @raw = raw
  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.

Since:

  • 0.5.0



31
32
33
34
35
# File 'lib/typhoeus/response/header.rb', line 31

def [](key)
  self.each do |k, v|
    return v if k.downcase == key.downcase
  end
end

#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



24
25
26
27
28
29
# File 'lib/typhoeus/response/header.rb', line 24

def parse
  raw.lines.each do |header|
    next if header.empty? || header =~ /^HTTP\/1.[01]/
    process_line(header)
  end
end