Sha256: 55e1725665c1b8b7ccc1d7ec520e7dc2cfa8da8e72f8a972355cbeba5213b41a
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module Typhoeus module Responses # This class represents the response header. # It can be accessed like a hash. class Header < Hash # Create a new header. # # @example Create new header. # Header.new(raw) # # @param [ String ] raw The raw header. def initialize(raw) @raw = raw parse end # Returns the raw header or empty string. # # @example Return raw header. # header.raw # # @return [ String ] The raw header. def raw @raw ||= '' end # Parses the raw header. # # @example Parse header. # header.parse def parse raw.lines.each do |header| unless header =~ /^HTTP\/1.[01]/ parts = header.split(':', 2) unless parts.empty? parts.map(&:strip!) if self.has_key?(parts[0]) self[parts[0]] = [self[parts[0]]] unless self[parts[0]].kind_of? Array self[parts[0]] << parts[1] else self[parts[0]] = parts[1] end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
typhoeus-0.5.0.alpha | lib/typhoeus/responses/header.rb |
typhoeus-0.5.0.pre | lib/typhoeus/responses/header.rb |