Class: Riak::Util::Headers
- Inherits:
-
Object
- Object
- Riak::Util::Headers
- Includes:
- Net::HTTPHeader
- Defined in:
- riak-client/lib/riak/util/headers.rb
Overview
Represents headers from an HTTP request or response. Used internally by HTTP backends for processing headers.
Class Method Summary (collapse)
-
+ (Object) parse(chunk)
Parse a single header line into its key and value.
Instance Method Summary (collapse)
-
- (Headers) initialize
constructor
A new instance of Headers.
-
- (Object) parse(chunk)
Parses a header line and adds it to the header collection.
Constructor Details
- (Headers) initialize
A new instance of Headers
44 45 46 |
# File 'riak-client/lib/riak/util/headers.rb', line 44 def initialize initialize_http_header({}) end |
Class Method Details
+ (Object) parse(chunk)
Parse a single header line into its key and value
50 51 52 53 54 55 56 |
# File 'riak-client/lib/riak/util/headers.rb', line 50 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 |
Instance Method Details
- (Object) parse(chunk)
Parses a header line and adds it to the header collection
60 61 62 63 |
# File 'riak-client/lib/riak/util/headers.rb', line 60 def parse(chunk) key, value = self.class.parse(chunk) add_field(key, value) if key && value end |