| Module | Net::HTTPHeader |
| In: |
lib/net/http.rb
|
Header module.
Provides access to @header in the mixed-into class as a hash-like object, except with case-insensitive keys. Also provides methods for accessing commonly-used header values in a more convenient format.
| size | -> | length |
Returns the header field corresponding to the case-insensitive key. For example, a key of "Content-Type" might return "text/html"
[Ruby 1.8.3] Adds header field instead of replace. Second argument val must be a String. See also #[]=, #[] and get_fields.
request.add_field 'X-My-Header', 'a'
p request['X-My-Header'] #=> "a"
p request.get_fields('X-My-Header') #=> ["a"]
request.add_field 'X-My-Header', 'b'
p request['X-My-Header'] #=> "a, b"
p request.get_fields('X-My-Header') #=> ["a", "b"]
request.add_field 'X-My-Header', 'c'
p request['X-My-Header'] #=> "a, b, c"
p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
Returns "true" if the "transfer-encoding" header is present and set to "chunked". This is an HTTP/1.1 feature, allowing the the content to be sent in "chunks" without at the outset stating the entire content length.
Returns an Integer object which represents the Content-Length: header field or nil if that field is not provided.
Returns a content type string such as "text/html". This method returns nil if Content-Type: header field does not exist.
As for each_header, except the keys are provided in capitalized form.
Returns the header field corresponding to the case-insensitive key. Returns the default value args, or the result of the block, or nil, if there‘s no header field named key. See Hash#fetch
[Ruby 1.8.3] Returns an array of header field strings corresponding to the case-insensitive key. This method allows you to get duplicated header fields without any processing. See also #[].
p response.get_fields('Set-Cookie')
#=> ["session=al98axx; expires=Fri, 31-Dec-1999 23:58:23",
"query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"]
p response['Set-Cookie']
#=> "session=al98axx; expires=Fri, 31-Dec-1999 23:58:23, query=rubyscript; expires=Fri, 31-Dec-1999 23:58:23"
Returns a content type string such as "text". This method returns nil if Content-Type: header field does not exist.
ruby-doc.org is hosted and maintained by James Britt and Rising Tide Software, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.