is there keep-alive support in HTTP_Request2?
| From: | Marc Vaillant | Date: | Mon, 24 Nov 2008 21:26:56 +0000 |
| Subject: | is there keep-alive support in HTTP_Request2? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-51133@lists.php.net to get a copy of this message | ||
I'm just trying out the nice HTTP_Request2 package and wondering if it's
supposed to have keep-alive support? Wrote a simple client using
HTTP_Request2 to a server that sends back multiple responses via
keep-alive. The client shuts down the connection after receiving the
first 2 responses. Attached is the code for the client.
If HTTP_Request2 doesn't support it then is there a package that does?
Thanks,
Marc
<?php require_once 'Request2.php'; $request = <<< XML <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime4="http://www.w3.org/2004/11/xmlmime" xmlns:FESOAPTYPE="AMFRS_ID_SOAP.xsd" xmlns:FESOAP="AMFRS_ID_SOAP.wsdl"> <SOAP-ENV:Body> <FESOAP:startProcessingVideo> <numberOfFramesForSaliency>0</numberOfFramesForSaliency> <numberOfFramesForId>0</numberOfFramesForId> <numberOfFramesToSkip>0</numberOfFramesToSkip> </FESOAP:startProcessingVideo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> XML; class ResponseObserver implements SplObserver { public function update( SplSubject $subject ) { $array = $subject->getLastEvent(); print_r($subject->getLastEvent()).PHP_EOL.PHP_EOL.PHP_EOL; echo "The subject is updating me\n"; } } $url = new Net_Url2("http://localhost:9022"); $urlRequest = new HTTP_Request2($url,HTTP_REQUEST2::METHOD_POST); $urlRequest->setBody($request); $observer = new ResponseObserver(); $urlRequest->attach($observer); $urlRequest->send(); ?>
<?php require_once 'Request2.php'; $request = <<< XML <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:xmime4="http://www.w3.org/2004/11/xmlmime" xmlns:FESOAPTYPE="AMFRS_ID_SOAP.xsd" xmlns:FESOAP="AMFRS_ID_SOAP.wsdl"> <SOAP-ENV:Body> <FESOAP:startProcessingVideo> <numberOfFramesForSaliency>0</numberOfFramesForSaliency> <numberOfFramesForId>0</numberOfFramesForId> <numberOfFramesToSkip>0</numberOfFramesToSkip> </FESOAP:startProcessingVideo> </SOAP-ENV:Body> </SOAP-ENV:Envelope> XML; class ResponseObserver implements SplObserver { public function update( SplSubject $subject ) { $array = $subject->getLastEvent(); print_r($subject->getLastEvent()).PHP_EOL.PHP_EOL.PHP_EOL; echo "The subject is updating me\n"; } } $url = new Net_Url2("http://localhost:9022"); $urlRequest = new HTTP_Request2($url,HTTP_REQUEST2::METHOD_POST); $urlRequest->setBody($request); $observer = new ResponseObserver(); $urlRequest->attach($observer); $urlRequest->send(); ?>