NAME

Net::Async::HTTP::Server::Request - represents a single outstanding request

DESCRIPTION

Objects in this class represent a single outstanding request received by a Net::Async::HTTP::Server instance. It allows access to the data received from the web client and allows responding to it.

METHODS

$method = $request->method

Return the method name from the request header.

$path = $request->path

Return the path name from the request header.

$query_string = $request->query_string

Return the query string from the request header.

$protocol = $request->protocol

Return the protocol version from the request header. This will be the full string, such as HTTP/1.1.

$value = $request->header( $key )

Return the value of a request header.

@headers = $request->headers

Returns a list of 2-element ARRAY refs containing all the request headers. Each referenced array contains, in order, the name and the value.

$body = $request->body

Return the body content from the request as a string of bytes.

$request->write( $data )

Append more data to the response to be written to the client. $data can either be a plain string, or a CODE reference to be used in the underlying IO::Async::Stream's write method.

$request->write_chunk( $data )

Append more data to the response in the form of an HTTP chunked-transfer chunk. This convenience is a shortcut wrapper for prepending the chunk header.

$request->done

Marks this response as completed.

$request->write_chunk_eof

Sends the final EOF chunk and marks this response as completed.

$req = $request->as_http_request

Returns the data of the request as an HTTP::Request object.

$request->respond( $response )

Respond to the request using the given HTTP::Response object.

$request->respond_chunk_header( $response )

Respond to the request using the given HTTP::Response object to send in HTTP/1.1 chunked encoding mode.

The headers in the $response will be sent (which will be modified to set the Transfer-Encoding header). Each call to write_chunk will send another chunk of data. write_chunk_eof will send the final EOF chunk and mark the request as complete.

If the $response already contained content, that will be sent as one chunk immediately after the header is sent.

$stream = $request->stream

Returns the IO::Async::Stream object representing this connection. Usually this would be used for such things as inspecting the client's connection address on the read_handle of the stream. It should not be necessary to directly perform IO operations on this stream itself.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>