NSURLSession-下载并不解压缩gzip? [英] NSURLSession - download and do *not* decompress gzip?

查看:44
本文介绍了NSURLSession-下载并不解压缩gzip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 NSURLSession dataTaskWithRequest 下载文件.将其压缩,并自动解压缩.但是,我不希望这样-我想要压缩后的源代码.有什么方法可以禁用减压功能吗?

I'm using NSURLSession's dataTaskWithRequest to download a file. It's gzipped, and it is automatically decompressed. However, I don't want it to be - I want the gzipped source. Is there any way to disable decompression?

推荐答案

NSURLSession 自动将此值插入到请求的标头中:

NSURLSession automatically inserts this value to your request's header:

"Accept-Encoding: gzip;q=1.0, compress;q=0.5"

导致下载的数据被自动解码.因此,我认为您应该先将"Accept-Encoding"的值替换为其他内容.

which causes the downloaded data to be automatically decoded. So I think you should start by replacing the value of "Accept-Encoding" with something else.

这篇关于NSURLSession-下载并不解压缩gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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