ID: 14872 Updated by: hholzgra Reported By: [EMAIL PROTECTED] Old Status: Open Status: Bogus Bug Type: Sockets related Operating System: RedHat Linux PHP Version: 4.0.6 New Comment:
Steve Meyers wrote: The performance loss is also due to using HTTP/1.1, which defaults to having keepalive on. Until you tell it to close the connection or it times out (about 2 seconds), it will keep it open. Switching to HTTP/1.0 fixes both issues. status changed to bogus as both issues where related to misunderstanding of HTTP concepts and not at all a PHP problem Previous Comments: ------------------------------------------------------------------------ [2002-01-05 09:55:16] [EMAIL PROTECTED] i don't know about the performance loss but the hex numbers you get are just what you requested by sending a HTTP/1.1 request you have declared that you are willing to 'speak' HTTP/1.1, and the HTTP/1.1 RFC 2616, Section 3.6 defines: [...] All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding, [...] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6 ------------------------------------------------------------------------ [2002-01-05 09:14:06] [EMAIL PROTECTED] What should happen: ================== The script is meant to create a printer-friendly version of a ski resort review page that is produced dynamically. It does this by opening a socket connection to the url, including the query, and read the contents of that url line by line looking for <!-- START CONTENTS --> and <!-- END CONTENTS --> tags. It echoes whatever is between those tags. What does happen: ================ The script works except for two issues. 1) In between some of the paragraphs of text some garbage hex numbers appear. They are always in the same place and the first two bytes are always the same. 2) The script runs extremely slowly which is attributed completely to the fsockopen() function. It should be noted that by simply replacing the fsockopen with fopen() the problems disappeared without any other changes to the code. Extraction from the Script that fails: ===================================== <? <snip> $fp=fsockopen($myServer,80,&$errno,&$errstr,30); $request = "GET $document"."?"."$query"." HTTP/1.1\r\n"; $request .= "Host: $myServer\r\n\r\n"; if(!$fp) { echo "$errstr ($errno)<br>\n"; } else { fputs($fp,$request); $content=0; $in_title=0; ?> </snip> <snip> <? while(!feof($fp)) { $line=fgets($fp,4096); if(ereg($START_CONT,$line)) { $content=1; } if(ereg($END_CONT,$line)) $content=0; if($content==1)echo $line; } fclose($fp); ?> Extraction from working script: ============================== <snip> <? $fp=fopen($myURL,r); //in place of fsockopen() // $request lines no longer required, removed. ?> </snip> Useful Links: ============ Full text of script with problem: www.ski-info-online.com/php-report/print-fails.txt Full test of script which works: www.ski-info-online.com/php-report/print-works.txt See working solution (click "printer-friendly version"): www.ski-info-online.com/skiResort-print1.php?id=Alpbach See problem (click "printer-friendly version"): www.ski-info-online.com/skiResort-fail.php?id=Alpbach Thanks Torrent ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14872&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]