Skip Menu |
 

This queue is for tickets about the HTTP-Server-Simple CPAN distribution.

Report information
The Basics
Id: 42546
Status: resolved
Priority: 0/
Queue: HTTP-Server-Simple

People
Owner: Nobody in particular
Requestors: JDB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.38
Fixed in: (no value)



Subject: t/04cgi.t fails test 20-21 on Windows
Download (untitled) / with headers
text/plain 682b
Happens with both 5.8.9 and 5.10.0: t/04cgi............ok 17/22 # Failed test 'Didn't decode already' # at t/04cgi.t line 63. # '' # doesn't match '(?-xism:foo%3Fbar)' t/04cgi............NOK 21/22 # Failed test 'Did decode already' # at t/04cgi.t line 68. # '' # doesn't match '(?-xism:foo/bar)' # Looks like you failed 2 tests of 22. t/04cgi............dubious Test returned status 2 (wstat 512, 0x200) DIED. FAILED tests 20-21 Failed 2/22 tests, 90.91% okay Failed Test Stat Wstat Total Fail List of Failed -------------------------------------------------------------- t/04cgi.t 2 512 22 2 20-21
I answered the similar problem in ticket #38011. But there was no response from the maintainer.
Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Tue, 20 Jan 2009 11:43:37 -0500
To: Radek via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: jesse <jesse [...] fsck.com>
Download (untitled) / with headers
text/plain 440b
Radek, I missed your reply. I'm sorry about that. I've queued it for dealing-with. Please keep prodding me if I don't deal in the next week or two. Best, Jesse On Tue, Jan 20, 2009 at 10:13:00AM -0500, Radek via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42546 > > > I answered the similar problem in ticket #38011. But there was no > response from the maintainer. >
--
Download (untitled) / with headers
text/plain 510b
I had the same problem and found the cause was errors in the tests. I could produce a patch, but it's simpler for me to just attach the fixed test file... The problem is on lines 63 and 69, which read: fetch("GET /cgitest/REQUEST_URI?foo%3Fbar",""), fetch("GET /cgitest/foo%2Fbar/PATH_INFO",""), while it should have been fetch("GET /cgitest/REQUEST_URI?foo%3Fbar HTTP/1.1",""), fetch("GET /cgitest/foo%2Fbar/PATH_INFO HTTP/1.1",""), With this fixed, the tests all pass.
Download 04cgi.t
text/x-perl 4.7k
use Test::More; use Socket; use strict; plan tests => 22; my $PORT = 8000 + $$; my $host = gethostbyaddr(inet_aton('localhost'), AF_INET); my %methods=( url => "url: http://$host:".$PORT, path_info => 'path_info: /cgitest/path_info', server_name => "server_name: $host", server_port => 'server_port: '.$PORT, server_software => 'server_software: HTTP::Server::Simple/\d+.\d+', request_method => 'request_method: GET', ); my %envvars=( SERVER_URL => "SERVER_URL: http://$host:".$PORT.'/', SERVER_PORT => 'SERVER_PORT: '.$PORT, REQUEST_METHOD => 'REQUEST_METHOD: GET', REQUEST_URI => 'REQUEST_URI: /cgitest/REQUEST_URI', SERVER_PROTOCOL => 'SERVER_PROTOCOL: HTTP/1.1', SERVER_NAME => "SERVER_NAME: $host", SERVER_SOFTWARE => 'SERVER_SOFTWARE: HTTP::Server::Simple/\d+.\d+', REMOTE_ADDR => 'REMOTE_ADDR: 127.0.0.1', QUERY_STRING => 'QUERY_STRING: ', PATH_INFO => 'PATH_INFO: /cgitest/PATH_INFO', ); { my $server=CGIServer->new($PORT); is($server->port(),$PORT,'Constructor set port correctly'); sleep(3); # wait just a moment my $pid=$server->background; like($pid, '/^-?\d+$/', 'pid is numeric'); select(undef,undef,undef,0.2); # wait a sec like(fetch("GET / HTTP/1.1",""), '/NOFILE/', 'no file'); foreach my $method (keys(%methods)) { like( fetch("GET /cgitest/$method HTTP/1.1",""), "/$methods{$method}/", "method - $method" ); select(undef,undef,undef,0.2); # wait a sec } foreach my $envvar (keys(%envvars)) { like( fetch("GET /cgitest/$envvar HTTP/1.1",""), "/$envvars{$envvar}/", "Environment - $envvar" ); select(undef,undef,undef,0.2); # wait a sec } like( fetch("GET /cgitest/REQUEST_URI?foo%3Fbar HTTP/1.1",""), qr/foo%3Fbar/, "Didn't decode already" ); like( fetch("GET /cgitest/foo%2Fbar/PATH_INFO HTTP/1.1",""), qr|foo/bar|, "Did decode already" ); is(kill(9,$pid),1,'Signaled 1 process successfully'); wait or die "counldn't wait for sub-process completion"; } sub fetch { my @response; my $alarm = 0; my $stage = "init"; my %messages = ( "init" => "inner contemplation", "lookup" => ("lookup of `localhost' - may be caused by a " ."missing hosts entry or broken resolver"), "sockaddr" => "call to sockaddr_in() - ?", "proto" => ("call to getprotobyname() - may be caused by " ."bizarre NSS configurations"), "socket" => "socket creation", "connect" => ("connect() - may be caused by a missing or " ."broken loopback interface, or firewalling"), "send" => "network send()", "recv" => "collection of response", "close" => "closing socket" ); $SIG{ALRM} = sub { @response = "timed out during $messages{$stage}"; $alarm = 1; }; my ($iaddr, $paddr, $proto, $message); $message = join "", map { "$_\015\012" } @_; my %states = ( 'init' => sub { "lookup"; }, "lookup" => sub { ($iaddr = inet_aton("localhost")) && "sockaddr" }, "sockaddr" => sub { ($paddr = sockaddr_in($PORT, $iaddr)) && "proto" }, "proto" => sub { ($proto = getprotobyname('tcp')) && "socket" }, "socket" => sub { socket(SOCK, PF_INET, SOCK_STREAM, $proto) && "connect" }, "connect" => sub { connect(SOCK, $paddr) && "send" }, "send" => sub { (send SOCK, $message, 0) && "recv" }, "recv" => sub { my $line; while (!$alarm and defined($line = <SOCK>)) { push @response, $line; } ($alarm ? undef : "close"); }, "close" => sub { close SOCK; "done"; }, ); # this entire cycle should finish way before this timer expires alarm(5); my $next; $stage = $next while (!$alarm && $stage ne "done" && ($next = $states{$stage}->())); warn "early exit from `$stage' stage; $!" unless $next; # bank on the test testing for something in the response. return join "", @response; } { package CGIServer; use base qw(HTTP::Server::Simple::CGI); use Env; sub handle_request { my $self=shift; my $cgi=shift; my $file=(split('/',$cgi->path_info))[-1]||'NOFILE'; $file=~s/\s+//g; $file||='NOFILE'; print "HTTP/1.0 200 OK\r\n"; # probably OK by now print "Content-Type: text/html\r\nContent-Length: "; my $response; if($methods{$file}) { $response = "$file: ".$cgi->$file(); } elsif($envvars{$file}) { $response="$file: $ENV{$file}"; } else { $response=$file; } print length($response), "\r\n\r\n", $response; } }
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Thu, 9 Apr 2009 19:16:47 -0400
To: BARTL via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Download (untitled) / with headers
text/plain 848b
Bart, Can you explain the _why_ of the change? HSS isn't an HTTP/1.1 server - it should work just fine with 0.9 or 1.0 requests. On Thu 9.Apr'09 at 17:53:14 -0400, BARTL via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42546 > > > I had the same problem and found the cause was errors in the tests. > > I could produce a patch, but it's simpler for me to just attach the > fixed test file... > > The problem is on lines 63 and 69, which read: > > fetch("GET /cgitest/REQUEST_URI?foo%3Fbar",""), > > fetch("GET /cgitest/foo%2Fbar/PATH_INFO",""), > > > while it should have been > > fetch("GET /cgitest/REQUEST_URI?foo%3Fbar HTTP/1.1",""), > > fetch("GET /cgitest/foo%2Fbar/PATH_INFO HTTP/1.1",""), > > > With this fixed, the tests all pass. >
RT-Send-CC: jesse [...] fsck.com
Download (untitled) / with headers
text/plain 691b
On Thu Apr 09 19:16:58 2009, jesse@fsck.com wrote: Why not to change tests as I described Jan 05 in a ticket #38011? Copied from the ticket correspondence: Show quoted text
________________________ When fetching with 0.9 protocol the line should read: fetch("GET /cgitest/REQUEST_URI?foo%3Fbar"), not fetch("GET /cgitest/REQUEST_URI?foo%3Fbar","") and the same for: fetch("GET /cgitest/foo%2Fbar/PATH_INFO"). The second parameter is intended for optional entity-body with http 1.0 and should be missing for http 0.9. The message is being composed like this: $message = join "", map { "$_\015\012" } @_; So there's another obligatory crlf for http 1.0.
________________________________________ Radek
Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Thu, 07 May 2009 08:26:40 +0200
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Download (untitled) / with headers
text/plain 528b
Hi, I agree with Radek - the following simple patch to 04cgi.t will solve it: ... like( - fetch("GET /cgitest/REQUEST_URI?foo%3Fbar",""), + fetch("GET /cgitest/REQUEST_URI?foo%3Fbar"), qr/foo%3Fbar/, "Didn't decode already" ); like( - fetch("GET /cgitest/foo%2Fbar/PATH_INFO",""), + fetch("GET /cgitest/foo%2Fbar/PATH_INFO"), qr|foo/bar|, "Did decode already" ); ... Tested with HTTP-Server-Simple-0.38 + strawberry perl 5.10.0 (all tests passed). -- kmx
Download (untitled) / with headers
text/plain 564b
Hi, Could you please consider applying the simple patch to 04cgi.t from previous post of this RT? I does not harm anything and according my tests (current stable v0.38 + the mentioned patch) on win32 strawberry perl 5.8.9 and 5.10.0 it makes this module installable on win32 without failing tests. I can prepare for you a PAUSE-ready-to-upload tar.gz archive with this patch applied or help in other way. Thanks. -- kmx P.S. IMPORTANT NOTICE: latest dev release 0.38_03 does not do well on Win32 (tests hang up); therefore I recommend reverting back to 0.38
Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Tue, 28 Jul 2009 15:59:37 -0400
To: K MX via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Download (untitled) / with headers
text/plain 821b
Please test 0.38_03, now on its way to cpan. thanks. On Mon 27.Jul'09 at 16:09:31 -0400, K MX via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42546 > > > Hi, > > Could you please consider applying the simple patch to 04cgi.t from > previous post of this RT? > > I does not harm anything and according my tests (current stable v0.38 + > the mentioned patch) on win32 strawberry perl 5.8.9 and 5.10.0 it makes > this module installable on win32 without failing tests. > > I can prepare for you a PAUSE-ready-to-upload tar.gz archive with this > patch applied or help in other way. > > Thanks. > > -- > kmx > > P.S. IMPORTANT NOTICE: latest dev release 0.38_03 does not do well on > Win32 (tests hang up); therefore I recommend reverting back to 0.38 >
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 243b
Show quoted text
> Please test 0.38_03, now on its way to cpan. thanks.
0.38_03 does not work well for me neither on win32 straberry perl 5.8.9 nor on 5.10.0 - 01live.t hangs up please do not release it yet, I will try to investigate further details -- kmx
Download (untitled) / with headers
text/plain 2.3k
Hi, I am back with my further analysis of Win32 issues. 1) Changes in background() introduced in 0.38_02/03 The implementation on background (the hack with temporary filehandle, sleeping etc.) simply hangs up on Win32. Firstly it uses some tricks that does not work on windows (like unlinking an open filehandle), next it tries to implement a sort of interprocess communication in a very unusual way - IPC was invented for this purpose and finally I I am not sure if we really need to wait till the child starts listening (yes, it might be a little trouble during tests where we want to connect to server immediately after calling background() but in a real program it will not happen so often). To sum up: I ask you to revert this changes. The minor change I propose in background() is to add "exit" after "run" - I know that run should never return, it is just to be sure. 2) fetch() function in 04cgi.t 01live.t The problem of these tests on Win32 was fetch() function using some SIGALRM stuff that works differently on UNIX and Windows. Generally it is good to know that on Win32 there are no native signals and perl on Win32 has just a sort of emulation (not all but just 4 basic trappable signals are emulated). SIGALRM is somehow emulated on Win32 but keep in mind, that the implementation is just on a perl level therefore for example using blocking tcp socket waiting for data somewhere in Windows kernel syscall cannot be interrupted by perl's $SIG{ALRM} trap. To solve this issue I have reimplemented fetch() function in 01live.t and 04cgi.t (it is not nice to duplicate the same function on two places; however I did not want to make too big changes). The new implementation uses non-blocking socket + select call for handling timeout; I have tried to keep a detailed diagnostics as in your previous version. Together with a little patch discussed in RT #48249 I put all changes to enclosed patch (it is against 0.38_03). For me it works on - win32/strawberry 5.8.9 and 5.10.0 - win32/cygwin 5.10.0 I propose: 1) apply this patch and release a a new dev release 0.38_04 2) we can ask all people submitting Win32-related RTs to test it 3) then it will be probably ready for release The only open question remains about whether we really need the background() to guarantee that when it returns the child is ready to accept request. I guess not, but if otherwise I would prefer some Win32 compliant way. -- kmx

Message body not shown because it is not plain text.

RT-Send-CC: jesse [...] fsck.com
Hi Jesse, do you have any feedback to my previous post with patch proposal? Thanks. -- kmx
Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Mon, 3 Aug 2009 16:27:50 +0100
To: kmx via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Download (untitled) / with headers
text/plain 342b
Sorry, I've been traveling to YAPC EU and have been crazy busy. I'm hoping to get to look at it this week. -j On Mon 3.Aug'09 at 10:40:29 -0400, kmx via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=42546 > > > Hi Jesse, > > do you have any feedback to my previous post with patch proposal? > > Thanks. > > -- > kmx >
Download (untitled)
application/pgp-signature 194b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #42546] t/04cgi.t fails test 20-21 on Windows
Date: Sat, 8 Aug 2009 16:25:35 +0100
To: kmx via RT <bug-HTTP-Server-Simple [...] rt.cpan.org>
From: Jesse Vincent <jesse [...] fsck.com>
Download (untitled) / with headers
text/plain 2.7k
This patch isn't applying on my 0.38_03 sources. Is there a chance it was generated unproperly? On Thu 30.Jul'09 at 15:39:18 -0400, kmx via RT wrote: Show quoted text
> Queue: HTTP-Server-Simple > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=42546 > > > Hi, > > I am back with my further analysis of Win32 issues. > > 1) Changes in background() introduced in 0.38_02/03 > > The implementation on background (the hack with temporary filehandle, > sleeping etc.) simply hangs up on Win32. Firstly it uses some tricks > that does not work on windows (like unlinking an open filehandle), next > it tries to implement a sort of interprocess communication in a very > unusual way - IPC was invented for this purpose and finally I I am not > sure if we really need to wait till the child starts listening (yes, it > might be a little trouble during tests where we want to connect to > server immediately after calling background() but in a real program it > will not happen so often). > > To sum up: I ask you to revert this changes. > > The minor change I propose in background() is to add "exit" after "run" > - I know that run should never return, it is just to be sure. > > 2) fetch() function in 04cgi.t 01live.t > > The problem of these tests on Win32 was fetch() function using some > SIGALRM stuff that works differently on UNIX and Windows. Generally it > is good to know that on Win32 there are no native signals and perl on > Win32 has just a sort of emulation (not all but just 4 basic trappable > signals are emulated). SIGALRM is somehow emulated on Win32 but keep in > mind, that the implementation is just on a perl level therefore for > example using blocking tcp socket waiting for data somewhere in Windows > kernel syscall cannot be interrupted by perl's $SIG{ALRM} trap. > > To solve this issue I have reimplemented fetch() function in 01live.t > and 04cgi.t (it is not nice to duplicate the same function on two > places; however I did not want to make too big changes). The new > implementation uses non-blocking socket + select call for handling > timeout; I have tried to keep a detailed diagnostics as in your previous > version. > > Together with a little patch discussed in RT #48249 I put all changes to > enclosed patch (it is against 0.38_03). For me it works on > - win32/strawberry 5.8.9 and 5.10.0 > - win32/cygwin 5.10.0 > > I propose: > 1) apply this patch and release a a new dev release 0.38_04 > 2) we can ask all people submitting Win32-related RTs to test it > 3) then it will be probably ready for release > > The only open question remains about whether we really need the > background() to guarantee that when it returns the child is ready to > accept request. I guess not, but if otherwise I would prefer some Win32 > compliant way. > > -- > kmx >
Download (untitled) / with headers
text/plain 629b
Show quoted text
> This patch isn't applying on my 0.38_03 sources. Is there a chance it > was generated unproperly?
I have used as a baseline this archive http://search.cpan.org/CPAN/authors/id/J/JE/JESSE/HTTP-Server-Simple-0.38_03.tar.gz let us have decompressed targz in: .../workdir/HTTP-Server-Simple-0.38_03/... let us have the diff: .../workdir/HTTP-Server-Simple-0.38_03patch.diff for me works this: .../workdir/HTTP-Server-Simple-0.38_03> patch -p 1 -i ..\HTTP-Server-Simple-0.38_03patch.diff patching file lib/HTTP/Server/Simple.pm patching file t/01live.t patching file t/04cgi.t Note: my diff file has CRLF as a newlines -- kmx
Attaching the whole patched module targz. -- kmx
Download HTTP-Server-Simple-0.38_03patch.tgz
application/x-compressed 25.5k

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 186b
Hi Jesse, the currently released devel version HTTP-Server-Simple-0.38_04 installs fine (no failing tests) on Win32/strawberry perl - I have tested both 5.8.9 and 5.10.0 Thanks -- kmx
Download (untitled) / with headers
text/plain 444b
Le Sam. Aoû. 08 14:53:34 2009, KMX a écrit : Show quoted text
> Note: my diff file has CRLF as a newlines
This should be avoided. I'm using 'makepatch' (CPAN distrib JV/makepatch-2.04.tar.gz) to create patches for CPAN distribs on Win32. Here are some tips to make it work on Win32: * put GNUWin32 patch.exe and diff.exe in your %PATH%. * my %HOME%\.makepatchrc: -diff "diff -urp --binary" * my %HOME%\.applypatchrc: -patch "patch -p0 -N --binary"


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.