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


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.



   $is_closed = $request->is_closed

Returns true if the underlying network connection for this request has already been closed. If this is the case, the application is free to drop the request object and perform no further processing on it.


   $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.


   %params = $request->query_form

Since version 0.09.

Return an even-sized list of name and value pairs that gives the decoded data in the query string. This is the same format as the same-named method on URI.


   @names = $request->query_param_names

Since version 0.09.

Return a list of the names of all the query parameters.


   $value = $request->query_param( $name )

   @values = $request->query_param( $name )

Since version 0.09.

Return the value or values of a single decoded query parameter.


   $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.



Marks this response as completed.



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.


   $status = $request->response_status_line

If a response header has been written by calling the write method, returns the first line of it.


   $code = $request->response_status_code

If a response header has been written by calling the write method, returns the status code from it.


Paul Evans <>