Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 85 lines (60 sloc) 1.786 kB
# This program only exists to figure out why perl 5.12.0 RC1 hangs when
# trying to test PUT in Test::WWW::Mechanize.
use strict;
use warnings;
use WWW::Mechanize;
my $server = HangServer->new;
my $pid = $server->background;
print "Running as pid $pid\n";
my $server_root = $server->root;
my $mech = WWW::Mechanize->new;
my $goodlinks = "$server_root/goodlinks.html";
$mech->get( $goodlinks );
$mech->success or die "Unable to get $goodlinks";
print "=== GET content ===\n";
print $mech->content, "\n";
print "=== GET content ===\n";
print "\n\nHit enter to do a PUT. You can also go elsewhere and connect to $server_root";
my $f = <>;
my $scraps = "$server_root/scraps.html";
$mech->put( $scraps );
print "=== PUT content ===\n";
print $mech->content, "\n";
print "=== PUT content ===\n";
print 'Success in the PUT? ', ($mech->success ? 'YES' : 'NO'), '\n';
print "\n\nHit enter to down the server";
$f = <>;
print "Killing pid $pid\n";
kill( 9, $pid ) unless $^S;
print "Server stopped\n";
package HangServer;
use warnings;
use strict;
use base 'HTTP::Server::Simple::CGI';
sub new {
my $class = shift;
# XXX This should really be a random port.
return $class->SUPER::new(13432, @_);
sub handle_request {
my $self = shift;
my $cgi = shift;
use Data::Dumper; local $Data::Dumper::Sortkeys=1;
my $response = Dumper($cgi);
$response .= '$cgi->path_info is [' . $cgi->path_info . ']';
print "HTTP/1.0 200 OK\r\n";
print "Content-Type: text/html\r\nContent-Length: ", length($response), "\r\n\r\n", $response;
sub root {
my $self = shift;
my $port = $self->port;
return "http://localhost:$port";
Jump to Line
Something went wrong with that request. Please try again.