Class: UU::OS::HTTP::HTTPHeaders
- Inherits:
-
Lang::UniformHash
- Object
- Hash
- Lang::UniformHash
- UU::OS::HTTP::HTTPHeaders
- Defined in:
- uu_os_connection-2.2.4/lib/uu/os/http/http_headers.rb
Overview
Object representing HTTP headers with Hash-like API.
Instance Method Summary (collapse)
-
- (void) add(name, value)
Appends value to header of given name.
-
- (TrueClass, FalseClass) contains(name, value = nil)
Returns true if headers contains header with given name and optional value.
Methods inherited from Lang::UniformHash
#[], #[]=, #default, #delete, #fetch, #has_key?, #has_value?, #include?, #key, #key?, #member?, #merge, #merge!, #replace, #store, #update, #value?, #values_at
Instance Method Details
- (void) add(name, value)
This method returns an undefined value.
Appends value to header of given name.
24 25 26 27 28 29 30 |
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_headers.rb', line 24 def add(name, value) if has_key?(name) self[name].concat(transform_value(value)) else self[name] = value end end |
- (TrueClass, FalseClass) contains(name, value = nil)
Returns true if headers contains header with given name and optional value.
37 38 39 40 41 42 43 44 |
# File 'uu_os_connection-2.2.4/lib/uu/os/http/http_headers.rb', line 37 def contains(name, value = nil) return false if !has_key?(name) return true if value.nil? self[name].each do |val| return true if val =~ /#{value}/ end return false end |