NAME

Drogo::Server::Test - Bare implementation of a server's methods, for testing.

METHODS

new

Create a new server instance.

Parameters (all optional):

uri            => '/some/path',
args           => 'a=1&b=2',          # query string
request_method => 'POST',             # defaults to GET
request_body   => 'a=1&b=2',          # body for POST requests
headers_in     => { cookie => '...' },
remote_addr    => '10.0.0.1',

After a dispatch the object holds what the application produced: output, status, http_header (content type) and headers_out.

variable(key => $value)

Returns a persistant server variable.

Key without value returns variable.

These include variables set by the server configuration, as "user variables" in nginx.

uri

Returns the uri.

args

Returns string of arguments.

request_body

Returns the request body (used for posts)

input

Returns input stream (an in-memory handle over the request body).

process_request_method

Mirrors the PSGI server: for POST requests, exposes the body through input and hands control to the dispatcher's body handler.

request_method

Returns the request method (GET or POST)

remote_addr

Returns remote address.

has_request_body

Used by nginx for request body processing.

This function is only called when the request method is a post, in an effort to reduce processing time.

header_in

Returns a request header. Lookup is case-insensitive.

header_out

Sets a header out. Setting the same header again keeps both values, as nginx does, so headers_out holds an array reference for repeated headers.

send_http_header

Send the http header.

$self->status(...)

Set output status... (200, 404, etc...) If no argument given, returns status.

print

Print stuff to the http stream.

sleep

Sleeps (used by nginx), not needed for other server implementations.

header_only

Returns true of only the header was requested.

unescape

Unescape an encoded uri.

server_return

This function defines what is returned to the server at the end of a dispatch. For nginx, this will be a status code, but in this test implementation we're returning the actual server object itself, so we can evaluate it while testing

AUTHORS

Bizowie <http://bizowie.com>

COPYRIGHT AND LICENSE

Copyright (C) 2013 Bizowie

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.