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


In reply to Re: Re: Re: Re: Re: Re: Re: using CGI on HTTP::Request from HTTP::Daemon by tachyon
in thread using CGI on HTTP::Request from HTTP::Daemon by gregor-e

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.