Hello!
Using the following script I try to get a html-page gzip-compressed, and
uncompress the body of the HTTP-message.
<?php
define(CRLF,"\xD\xA");
$host = "selfforum.teamone.de";
$path = "/";
$fp = fsockopen($host, 80);
$header = "GET ".$path." HTTP/1.0".CRLF;
$header .= "Accept-Encoding: gzip".CRLF;
$header .= "Host: ".$host.CRLF;
$header .= CRLF;
fputs($fp, $header);
while(!feof($fp)) {
$result .= fread($fp,1);
}
fclose($fp);
$compressed_result = explode(CRLF.CRLF, $result, 2);
echo "length: " strlen($compressed_result[1])."\n"; // length of compressed
message
// without header, to
compare
// with content-length
header
echo gzuncompress($compressed_result[1]);
?>
I get the following error:
Warning: gzuncompress: data error in /www/webseite/temp/sock2.php on line 32
Line 32: echo gzuncompress($compressed_result[1]);
>From server I get HTTP-response "contend-encoding: gzip", HTTP-Statuscode
"200",
the content-length in HTTP header is the same as my own echo "length: "
strlen($compressed_result[1]).";
$compressed_result[1] contains binary data, no plain-text.
gzcompress and gzuncompress usually work without problems in.
Server-OS: Linux 2.4
Webserver: Apache 1.3.26
PHP 4.2.3.(CGI)
Perhaps there are some charakters form binary gzip-code interpretet as
functional character, could I escape something here? Or some problems with
line-breaks, or blanks? I have no idea whats going wrong here. I hope
someone here knows what to do or where to look for errors!
Thank you,
Andreas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php