Par*_*oft 30 php curl gzip gunzip
有谁知道如何解压缩我用curl得到的gzip文件的内容?
例如:http://torcache.com/torrent/63ABC1435AA5CD48DCD866C6F7D5E80766034391.torrent
回应
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 09 Jun 2010 01:11:26 GMT
Content-Type: application/x-bittorrent
Content-Length: 52712
Last-Modified: Tue, 08 Jun 2010 15:09:58 GMT
Connection: keep-alive
Expires: Fri, 09 Jul 2010 01:11:26 GMT
Cache-Control: max-age=2592000
Content-Encoding: gzip
Accept-Ranges: bytes
Run Code Online (Sandbox Code Playgroud)
那么压缩的gzip,
我试过gzdecode但是不起作用,gzeflate也不是他们根本没有得到任何回复,文件的内容不超过2k
mix*_*dev 76
只需告诉cURL,只要它被压缩,就会自动解码响应
curl_setopt($ch,CURLOPT_ENCODING, '');
Run Code Online (Sandbox Code Playgroud)
Art*_*cto 14
用途gzdecode
:
<?php
$c = file_get_contents("http://torcache.com/" .
"torrent/63ABC1435AA5CD48DCD866C6F7D5E80766034391.torrent");
echo gzdecode($c);
Run Code Online (Sandbox Code Playgroud)
给
d8:announce42:http://tracker.openbittorrent.com/announce13:announce-listll42 ...
Dan*_*erg 12
libcurl提供了一种功能,可以自动解压缩内容(如果使用zlib构建).
请参阅CURLOPT_ENCODING选项:http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTENCODING