在 php 上从 CURL 解压缩 gzip 文件 [英] Uncompress a gzip file from CURL, on php

查看:58
本文介绍了在 php 上从 CURL 解压缩 gzip 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何解压缩我用 curl 得到的 gzip 文件的内容?

例如:http://torcache.com/torrent/63ABC1435AA5CD48DCD866C6037>

回复了

HTTP/1.1 200 OK服务器:nginx日期:2010 年 6 月 9 日,星期三 01:11:26 GMT内容类型:应用程序/x-bittorrent内容长度:52712最后修改时间:2010 年 6 月 8 日,星期二 15:09:58 GMT连接:保持连接到期: 2010 年 7 月 9 日星期五 01:11:26 GMT缓存控制:max-age=2592000内容编码:gzip接受范围:字节

然后是压缩的gzip,

我试过 gzdecode 但没有用,gzeflate 也是,他们根本就没有得到任何响应,而且文件的内容不超过 2k

使用 gzdecode:

给予

<前>d8:announce42:http://tracker.openbittorrent.com/announce13:announce-listll42...

Does anyone know how to uncompress the contents of a gzip file that i got with curl?

for example: http://torcache.com/torrent/63ABC1435AA5CD48DCD866C6F7D5E80766034391.torrent

responded

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

then the compressed gzip,

i tried gzdecode but doesn't work , gzeflate as well doesn't they simply don't get any response, and the contents of the files are no more than 2k

解决方案

Use gzdecode:

<?php
    $c = file_get_contents("http://torcache.com/" .
        "torrent/63ABC1435AA5CD48DCD866C6F7D5E80766034391.torrent");
    echo gzdecode($c);

gives

d8:announce42:http://tracker.openbittorrent.com/announce13:announce-listll42
...

这篇关于在 php 上从 CURL 解压缩 gzip 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆