Sha256: e0a905f4d107c74a7f115d5a3592e37de99599edfa36753e011b3d83973042a7
Contents?: true
Size: 925 Bytes
Versions: 2
Compression:
Stored size: 925 Bytes
Contents
require 'net/http' module Riak module Util # Represents headers from an HTTP request or response. # Used internally by HTTP backends for processing headers. class Headers include Net::HTTPHeader def initialize initialize_http_header({}) end # Parse a single header line into its key and value # @param [String] chunk a single header line def self.parse(chunk) line = chunk.strip # thanks Net::HTTPResponse return [nil,nil] if chunk =~ /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in m = /\A([^:]+):\s*/.match(line) [m[1], m.post_match] rescue [nil, nil] end # Parses a header line and adds it to the header collection # @param [String] chunk a single header line def parse(chunk) key, value = self.class.parse(chunk) add_field(key, value) if key && value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riak-client-1.4.5 | lib/riak/util/headers.rb |
riak-client-1.4.4.1 | lib/riak/util/headers.rb |