Test-HTTP-LocalServer
view release on metacpan or search on metacpan
(CPAN testers failure at
http://www.cpantesters.org/cpan/report/55b7db81-6bfd-1014-acc9-ccd2be2b35a3 )
0.70 2020-01-07
* Protect the main exit code in $? against child exit code leaking, and
add some more tests against this. This should fix downstream test
failures in WWW::Mechanize::Chrome.
* More automated CI testing
0.69 2019-10-01
* Protect test suite against HTTP_PROXY (etc) being set, again
This is mostly because the module itself doesn't care anymore, but now
the test suite needs to protect itself.
0.68 2019-09-30
* Add ->basic_auth endpoint
0.67 2019-09-29
* More aggressively watch for startup of the web server to reduce idle
times. Also speed up the test suite by polling instead of sleep()ing.
* Added ->server_url() as a half-documented way of changing the URL
HTTP::Tiny (core since 5.14, runs on 5.6+).
0.66 2019-09-10
* Make detection of IPv4 localhost vs. IPv6 localhost
much more resilient. Backported from WWW::Mechanize, implemented by
Shoichi Kaji.
* We now need HTTP::Daemon 6.05.
0.65 2019-09-05
* Fix order of module usage in test scripts, spotted by Jorol
This only was a problem when you had $ENV{HTTP_PROXY} set.
* Document that we clean out $ENV{HTTPS_PROXY} as well.
0.64 2018-10-28
* Re-release including correct META.* information
* No upgrade necessary
0.63 2018-06-04
* Fix the form parameters getting lost
This was since we changed the form from GET to POST ...
README.mkdn view on Meta::CPAN
Try to avoid characters that are special to the shell, especially quotes.
A good idea for a slow server would be
eval => sleep+10
All served HTML will have the first %s replaced by the current location.
The following entries will be removed from `%ENV` when making a request:
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
## `$server->port`
This returns the port of the current server. As new instances
will most likely run under a different port, this is convenient
if you need to compare results from two runs.
## `$server->url`
lib/Test/HTTP/LocalServer.pm view on Meta::CPAN
A good idea for a slow server would be
eval => sleep+10
=back
All served HTML will have the first %s replaced by the current location.
The following entries will be removed from C<%ENV> when making a request:
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
=cut
sub get {
my( $url ) = @_;
local *ENV;
delete @ENV{qw(
HTTP_PROXY http_proxy CGI_HTTP_PROXY
HTTPS_PROXY https_proxy HTTP_PROXY_ALL http_proxy_all
ALL_PROXY
all_proxy
)};
my $response = HTTP::Tiny->new->get($url);
$response->{content}
}
sub spawn_child_win32 { my ( $self, @cmd ) = @_;
local $?;
system(1, @cmd)
t/01-start.t view on Meta::CPAN
use strict;
use warnings;
use Test::HTTP::LocalServer;
use HTTP::Tiny;
use Test::More tests => 4;
sub get {
my( $url ) = @_;
local @ENV{ qw[
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
] };
HTTP::Tiny->new->get( $url )->{content};
}
my $server = Test::HTTP::LocalServer->spawn(
# debug => 1
);
t/03-sticky-fields.t view on Meta::CPAN
my $server = Test::HTTP::LocalServer->spawn(
# debug => 1
);
my $pid = $server->{_pid};
my $res = kill 0, $pid;
is $res, 1, "PID $pid is an existing process";
local @ENV{ qw[
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
] };
my $ua = HTTP::Tiny->new();
$res = $ua->get( $server->url );
ok $res->{success}, "Retrieve " . $server->url;
$res = $ua->post_form( $server->url, [query => 'test1'] );
t/05-basic-auth.t view on Meta::CPAN
use Test::HTTP::LocalServer;
use HTTP::Tiny;
use Test::More tests => 5;
my $server = Test::HTTP::LocalServer->spawn(
# debug => 1,
);
local @ENV{ qw[
HTTP_PROXY
http_proxy
HTTP_PROXY_ALL
http_proxy_all
HTTPS_PROXY
https_proxy
CGI_HTTP_PROXY
ALL_PROXY
all_proxy
] };
my $pid = $server->{_pid};
my $res = kill 0, $pid;
is $res, 1, "PID $pid is an existing process";
my $challenge_url = $server->basic_auth('foo','secret');
( run in 0.518 second using v1.01-cache-2.11-cpan-71847e10f99 )