in reply to Re: Re: Re: Re: Re: Re: using CGI on HTTP::Request from HTTP::Daemon
in thread using CGI on HTTP::Request from HTTP::Daemon
Actually I am not sure I know how to fix it! Have a look at this test code (it hangs). This is a minimal case that simply shows how read() will block on reads from $conn.
#!/usr/bin/perl -w use strict; use HTTP::Daemon; use HTTP::Status; my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 80, ) or die "No daemon: $!\n"; warn "Ready to go!\n"; while (my $conn = $d->accept()) { serve_everything( $conn, $conn->get_request( 1 )); } sub serve_everything { my ($conn, $req) = @_; my $length = $req->content_length || 0; local *main::STDIN = $conn; my $data = ''; my $buf; if ( $length ) { print "Expecting $length bytes\n"; while( read( STDIN, $buf, 16 ) ) { print "Got: $buf\n"; $data .= $buf; } } else { $data = "Nothing Posted\n"; } my $HTML = qq!<pre>$data</pre> <hr> <FORM METHOD="POST" ACTION="http://localhost" ENCTYPE="mu +ltipart/form-data"> <INPUT TYPE="file" NAME="upload_file1" SIZE="42"> <INPUT TYPE="submit"> </FORM> !; $conn->send_response( HTTP::Response->new( 200, 'OK', HTTP::Headers->new( Content_Type => "text/html" ) , $HTML ) ); $conn->print( 'nope', $@ ) if $@; }
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Re: Re: using CGI on HTTP::Request from HTTP::Daemon
by PodMaster (Abbot) on May 26, 2004 at 04:48 UTC | |
by tachyon (Chancellor) on May 26, 2004 at 06:05 UTC |