- CLASS->new( STRREF, IS_RESPONSE, IS_LAME )
- CLASS->new_response( [ CODE ] )
- $obj->add_param( KEY, VALUE )
- $obj->param( [ KEY ] )
- $obj->http_code_english( [ CODE ] )
- $obj->code( CODE [, TEXT] )
- $obj->cookie( NAME )
- $obj->cookie( NAME, VALUE [, PARAMS] )
- $obj->filename( [ STRING ] )
- $obj->mime_type( [ STRING ] )
- $obj->path_info( [ STRING ] )
- $obj->version_number( [ VER ] )
- $obj->header( KEY [, VALUE ] )
- $obj->set_version( VER )
- $obj->req_keep_alive( RESPONSE_HEADERS )
- $obj->res_keep_alive( REQUEST_HEADERS )
- $obj->range( SIZE )
AxKit2::HTTPHeaders - HTTP Request and Response header class
This class parses and encapsulates HTTP headers, including the request/response line (e.g. GET / HTTP/1.0).
Construct a new header object from the given
STRREF. Assumes the header is a response header if
IS_RESPONSE is set. Assumes
IS_LAME is set.
Create a new response header with response code
CODE (default: 200 "OK").
Assumes response is HTTP/1.0.
Parse the request URI for querystring parameters.
Add a new param (see
Returns all params for
KEY in LIST context, or the last param for
KEY in SCALAR context.
Returns a list of current params if
KEY is not supplied.
Returns the english equivalent for HTTP response code
CODE. If code is not supplied uses the current response code (not valid for request headers).
Sets the response code to
CODE with optional
Gets the response code.
Gets the request method (e.g. "GET", "POST", etc).
Gets the request URI. Returns the full URI inclusive of query string.
Also callable as
Returns a list of values for the given cookie
NAME in LIST context, or the last set cookie for the given cookie
NAME in scalar context. Only works on request headers.
Set the cookie called
NAME with value
If value is an arrayref sets a multi-valued cookie.
Optional params are key-value pairs as per the cookie spec, e.g.:
$header->cookie( foo => "bar", path => "/", secure => 1 );
expires is not parsed and does not take formats such as "+1d". It is suggested to use
max-age instead (as per RFC 2109) which is a timeout in seconds from the current time.
Gets/Sets the request filename value.
Gets/Sets the request MIME type.
Gets/Sets the request path-info value.
Gets/Sets the header version number. Uses the form
MAJOR * 1000 + MINOR, so HTTP/1.0 will return
1000 and HTTP/0.9 will return
Returns the very first line of the request as seen.
Get/Set the value for a given header.
Returns true if the request was a HTTP/0.9 request.
Returns a reference to a string representing the headers in full.
Clone the current header object. Returns a new
Set the HTTP version using the
Using all available information, attempt to determine the content length of the message body being sent to us.
$obj is the request headers, answers the question: "should a response to this person specify keep-alive, given the request and the given response?"
This is used in proxy mode to determine based on the client's request and the backend's response whether or not the response from the proxy (us) should do keep-alive.
For normal responses (should a response be kept alive) see
Determine if an options response from a backend looks like it can do keep-alive.
$obj is the response headers, answers the question: "is the backend expected to stay open?" this is a combination of the request we sent to it and the response they sent...
You don't normally need to call this - it is automatically performed by the backend.
Given a size, returns
STATUS, RANGE_START, RANGE_END.
Status will be one of:
200 - Invalid or non-existant range header. Serve normally.
206 - Parsable range is good. Serve partial content.
416 - Range is unsatisfiable.