On Pon. 12 Cze. 2006, 19:06:58, guest wrote:
Show quoted text> if the socket is blocking sysread can block, if you don't want
> this use nonblocking sockets (whcih got better support with version
> 0.98). But it shouldn't block too much, e.g if yousaid sysread
> that you need only 512 bytes it will not wait until EOF but only
> until it got 512 bytes (assuming that there are more then 512
> bytes to read).
What if I don't know how many bytes should I read before sending some
response? Note that you shouldn't have to wait for EOF, because you may
want to read something, send some response, and then read again.
Currently, with blocking read that doesn't break at CR/LF (like system
read() does), it's impossible to implement such behavior, you would have
to use non-blocking operations and idle loops, or use read(1) to get
first line of received text.
This will cause problems when implementing i.e. POP, IMAP or whatever
text-oriented protocol over SSL using IO::Socket::SSL, where you have to
read one line, and then send something in response, before you get any
other input.
Show quoted text> But could you please send an example program which shows the problem
> so that I could have a closer look at it?
$httpserver = HTTP::Daemon::SSL->new(
Reuse => 1,
LocalAddr => $ip,
LocalPort => $port,
($SSLKey ? (SSL_key_file => $SSLKey) : ()),
($SSLCert ? (SSL_cert_file => $SSLCert) : ())
);
my $c = $httpserver->accept;
my $r = $c->get_request;
print "Method: ".$r->method."\n";
In HTTP::Daemon::SSL get_request() uses _need_more(), which has the
line:
my $n = sysread($self, $_[0], 2048, length($_[0]));
sysread is from IO::Socket:SSL, and uses IO::Socket::SSL::read.
HTTP request is usually shorter than 2kB, so this read() waits
indefinitely.