Net_Server interface (bug?)
| From: | luca\.mariano\@email\.it | Date: | Mon, 10 Nov 2003 09:39:44 +0000 |
| Subject: | Net_Server interface (bug?) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-23377@lists.php.net to get a copy of this message | ||
Hi,
I'm facing a problem with Net_Server interface. The method Net_Server::readFromSocket() seems
to fail when the received string does not have any terminator char (like "\n").
Test this:
<?php
// server base class
require_once 'Net/Server.php';
// base class for the hanlder
require_once 'Net/Server/Handler.php';
class testHandler extends Net_Server_Handler {
function onReceiveData($clientId = 0, $data = "")
{
print ("[Into testHandler] I received this :". $data . "\n");
$this->_server->sendData($clientId, "HTTP/1.1 501 Method Not Implemented
\r\n", true);
$this->_server->closeConnection($clientId);
}
}
// create a new server with the choosen layout
$server = & Net_Server::create("sequential", localhost, 8080);
$server->setDebugMode(true);
$handler = & new testHandler;
// hand over the object that handles server events
$server->setCallbackObject(& $handler);
// start the server
$server->start();
This simple HTTP listener works with GET requests, but fails with POST... Using a simple POST form
that points to http://localhost:8080/ you can see the server
locked into the readFromSocket() cycle.
After some investigations, I foud that a valid POST request must not be followed by a CRLF
(according to RFC-2616, sec. 4.1 - message types :
"Certain buggy HTTP/1.0 client implementations generate extra CRLF's
after a POST request. To restate what is explicitly forbidden by the
BNF, an HTTP/1.1 client MUST NOT preface or follow a request with an
extra CRLF."
).
In fact, a POST request created by Internet Explorer 6.0 does not have a CRLF at the end of HTTP
request, this prevent Net_Server to work because the read cycle became an infinite loop. With
Netscape 7.0 the request string is avaible because it ends with a "\n" (buggy client?)...
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Stai già pensando ai regali di Natale? Da Enoteca Squillari puoi trovare cesti
Assortiti e raffinati con i migliori prodotti della gastronomia italiana
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=1975&d=10-11