【问题标题】:Get the compressed response data with NSURLConnection?使用 NSURLConnection 获取压缩的响应数据?
【发布时间】:2011-10-25 16:00:41
【问题描述】:

当我向我的 NSURLRequest 添加“Accept-Encoding: gzip”标头字段时,NSURLConnection.sendSynchronousRequest 从服务器请求压缩数据并自动解压缩响应数据。有没有办法防止这种情况,即获取压缩(仍然是 gzip 压缩的)数据?

问候, 乔辰

【问题讨论】:

    标签: ios nsurlconnection nsurlrequest


    【解决方案1】:

    这种事情是在 Mac OS X 上使用 NSURLDownload 类完成的。Apple says:

    iOS 注意:NSURLDownload 类在 iOS 中不可用,因为 不鼓励直接下载到文件系统。使用 NSURLConnection 类代替。有关更多信息,请参阅“使用 NSURLConnection” 信息。

    因此,您需要评估您的选项 - 并使用 some library to zip it 返回并保存它。

    【讨论】:

    • 在iOS上运行,让系统解压然后自己再压缩可能不是最好的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 2020-12-11
    • 2019-04-13
    • 2013-05-21
    • 1970-01-01
    相关资源
    最近更新 更多