Manpage logo

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

NAME  DESCRIPTION  METHODS  is_closed  method  path  query_string  query_form  query_param_names  query_param  protocol  header  headers  body  write  write_chunk  done  write_chunk_eof  as_http_request  respond  respond_chunk_header  stream  response_status_line  response_status_code  AUTHOR 

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

is_closed

$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

$method = $request−>method;

Return the method name from the request header.

path

$path = $request−>path;

Return the path name from the request header.

query_string

$query_string = $request−>query_string;

Return the query string from the request header.

query_form

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

query_param_names

@names = $request−>query_param_names;

Since version 0.09.

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

query_param

$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

$protocol = $request−>protocol;

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

header

$value = $request−>header( $key );

Return the value of a request header.

headers

@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

$body = $request−>body;

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

write

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

write_chunk

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

done

$request−>done;

Marks this response as completed.

write_chunk_eof

$request−>write_chunk_eof;

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

as_http_request

$req = $request−>as_http_request;

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

respond

$request−>respond( $response );

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

respond_chunk_header

$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

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

response_status_line

$status = $request−>response_status_line;

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

response_status_code

$code = $request−>response_status_code;

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

AUTHOR

Paul Evans <[email protected]>


Updated 2026-06-01 - jenkler.se | uex.se