NAME
HTTP::WebTest::Utils - Miscellaneous subroutines used by HTTP::WebTest
SYNOPSIS
use HTTP::WebTest::Utils;
*method = make_access_method($field);
*method = make_access_method($field, $default_value);
*method = make_access_method($field, sub { ... });
find_port(hostname => $hostname);
my $pid = start_webserver(port => $port, server_sub => sub { ... });
stop_webserver($pid);
copy_dir($src_dir, $dst_dir);
load_package($package);
my $ret = eval_in_playground($code);
die $@ if $@;
DESCRIPTION
This packages contains utility subroutines used by HTTP::WebTest. All of them can be exported but none of them is exported by default.
SUBROUTINES
make_access_method($field, $optional_default_value)
Creates anonymous subroutine which can be used as accessor method. Method can be used with objects that are blessed hashes.
Typical usage is
*method = make_access_method($field, ...);
Parameters
$field
A hash field used for created accessor method.
$optional_default_value
If
$optional_default_value
is a code reference, uses values returned by its execution as default for created accessor method. Otherwise, uses$optional_default_value
as name of method which returns default value for created accessor method.
Returns
find_port (hostname => $hostname)
Returns
Free port number for network interface specified by $hostname
.
start_webserver(%params)
Starts separate process with a test webserver.
Parameters
- port => $port
-
A port number where the test webserver listens for incoming connections.
- server_sub => $server_sub
-
A reference on a subroutine to handle requests. It get passed two named parameters:
connect
andrequest
.
stop_webserver($pid)
Kills a test webserver specified by its PID.
copy_dir ($src_dir, $dst_dir)
Copies directiory recursively.
load_package ($package)
Loads package unless it is already loaded.
eval_in_playground ($code)
Evaluates perl code inside playground package.
Returns
A return value of evaluated code.
make_sub_in_playground ($code)
Create anonymous subroutine inside playground package.
Returns
A reference on anonymous subroutine.
COPYRIGHT
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.