Module FTW::HTTP::Message
In: lib/ftw/http/message.rb
lib/ftw/http/message.rb

HTTP Message, RFC2616 For specification, see RFC2616 section 4: <tools.ietf.org/html/rfc2616#section-4>

You probably won‘t use this class much. Instead, check out {FTW::Request} and {FTW::Response}

Methods

[]   []   []=   []=   body   body   body=   body=   body?   body?   content?   content?   new   new   to_s   to_s   version=   version=  

Included Modules

FTW::CRLF FTW::CRLF

Constants

VALID_VERSIONS = [1.0, 1.1]   HTTP Versions that are valid.
UnsupportedHTTPVersion = Class.new(ArgumentError)   For backward-compatibility, this exception inherits from ArgumentError
VALID_VERSIONS = [1.0, 1.1]   HTTP Versions that are valid.
UnsupportedHTTPVersion = Class.new(ArgumentError)   For backward-compatibility, this exception inherits from ArgumentError

Attributes

headers  [R]  The HTTP headers - See {FTW::HTTP::Headers}. RFC2616 5.3 - <tools.ietf.org/html/rfc2616#section-5.3>
headers  [R]  The HTTP headers - See {FTW::HTTP::Headers}. RFC2616 5.3 - <tools.ietf.org/html/rfc2616#section-5.3>
version  [RW]  The HTTP version. See {VALID_VERSIONS} for valid versions. This will always be a Numeric object. Both Request and Responses have version, so put it in the parent class.
version  [RW]  The HTTP version. See {VALID_VERSIONS} for valid versions. This will always be a Numeric object. Both Request and Responses have version, so put it in the parent class.

Public Class methods

A new HTTP message.

A new HTTP message.

Public Instance methods

Get a header value by field name.

@param [String] the name of the field. (case insensitive)

Get a header value by field name.

@param [String] the name of the field. (case insensitive)

Set a header field

@param [String] the name of the field. (case insensitive) @param [String] the value to set for this field

Set a header field

@param [String] the name of the field. (case insensitive) @param [String] the value to set for this field

Get the body of this message

Returns an Enumerable, IO-like object, or String, depending on how this message was built.

Get the body of this message

Returns an Enumerable, IO-like object, or String, depending on how this message was built.

Set the body of this message

The ‘message_body’ can be an IO-like object, Enumerable, or String.

See RFC2616 section 4.3: <tools.ietf.org/html/rfc2616#section-4.3>

Set the body of this message

The ‘message_body’ can be an IO-like object, Enumerable, or String.

See RFC2616 section 4.3: <tools.ietf.org/html/rfc2616#section-4.3>

Does this message have a body?

Does this message have a body?

Should this message have a content?

In HTTP 1.1, there is a body if response sets Content-Length or Transfer-Encoding, it has a body. Otherwise, there is no body.

Should this message have a content?

In HTTP 1.1, there is a body if response sets Content-Length or Transfer-Encoding, it has a body. Otherwise, there is no body.

Serialize this Request according to RFC2616 Note: There is NO trailing CRLF. This is intentional. The RFC defines:

    generic-message = start-line
                      *(message-header CRLF)
                      CRLF
                      [ message-body ]

Thus, the CRLF between header and body is not part of the header.

Serialize this Request according to RFC2616 Note: There is NO trailing CRLF. This is intentional. The RFC defines:

    generic-message = start-line
                      *(message-header CRLF)
                      CRLF
                      [ message-body ]

Thus, the CRLF between header and body is not part of the header.

Set the HTTP version. Must be a valid version. See VALID_VERSIONS.

Set the HTTP version. Must be a valid version. See VALID_VERSIONS.

[Validate]