Class HTTP::Message::Headers
In: lib/httpclient/http.rb
Parent: Object

Represents HTTP message header.

Methods

[]   []=   add   all   body_size=   contenttype   contenttype=   delete   dump   get   init_connect_request   init_request   init_response   new   set   status_code=  

Constants

STATUS_CODE_MAP = { Status::OK => 'OK', Status::CREATED => "Created", Status::NON_AUTHORITATIVE_INFORMATION => "Non-Authoritative Information", Status::NO_CONTENT => "No Content", Status::RESET_CONTENT => "Reset Content", Status::PARTIAL_CONTENT => "Partial Content", Status::MOVED_PERMANENTLY => 'Moved Permanently', Status::FOUND => 'Found', Status::SEE_OTHER => 'See Other', Status::TEMPORARY_REDIRECT => 'Temporary Redirect', Status::MOVED_TEMPORARILY => 'Temporary Redirect', Status::BAD_REQUEST => 'Bad Request', Status::INTERNAL => 'Internal Server Error', }   HTTP response status code to reason phrase mapping definition.
CHARSET_MAP = { 'NONE' => 'us-ascii', 'EUC' => 'euc-jp', 'SJIS' => 'shift_jis', 'UTF8' => 'utf-8', }   $KCODE to charset mapping definition.
NIL_URI = URI.parse('http://nil-uri-given/')   Placeholder URI object for nil uri.

Attributes

body_size  [R]  Size of body. nil when size is unknown (e.g. chunked response).
chunked  [RW]  Request/Response is chunked or not.
http_version  [RW]  HTTP version in a HTTP header. Float.
reason_phrase  [RW]  Response only. HTTP status reason phrase.
request_method  [R]  Request only. Requested method.
request_query  [RW]  Request only. Requested query.
request_uri  [RW]  Request only. Requested URI.
request_via_proxy  [RW]  Request only. Requested via proxy or not.
status_code  [R]  Response only. HTTP status

Public Class methods

Creates a Message::Headers. Use init_request, init_response, or init_connect_request for acutual initialize.

Public Instance methods

Returns an Array of header values for the given key.

Adds a header. See set.

Adds a header. Addition order is preserved.

Returns an Array of all headers.

Sets byte size of message body. body_size == nil means that the body is_a? IO

Returns ‘Content-Type’ header value.

Sets ‘Content-Type’ header value. Overrides if already exists.

Deletes headers of the given key.

Dumps message header part and returns a dumped String.

Returns an Array of headers for the given key. Each element is a pair of key and value. It returns an single element Array even if the only one header exists. If nil key given, it returns all headers.

Initialize this instance as a CONNECT request.

Initialize this instance as a general request.

Initialize this instance as a response.

Sets a header.

Sets status code and reason phrase.

[Validate]