首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >接收到内容编码的响应: gzip,但未能解码它。

接收到内容编码的响应: gzip,但未能解码它。
EN

Stack Overflow用户
提问于 2018-11-22 17:21:38
回答 1查看 5.6K关注 0票数 2

当发出GET请求时

代码语言:javascript
运行
复制
https://apicache.vudu.com/api2/?_type=contentSearch&contentEncoding=gzip&contentId={}&dimensionality=any&followup=ultraVioletability&followup=longCredits&followup=superType&followup=episodeNumberInSeason&followup=advertContentDefinitions&followup=tag&followup=hasBonusWithTagExtras&followup=subtitleTrack&followup=ratingsSummaries&followup=geneGenres&followup=seasonNumber&followup=trailerEditionId&followup=genres&followup=usefulStreamableOffers&followup=walmartOffers&followup=preOrderOffers&followup=editions&followup=merchandiseContentMaps&followup=promoTags&followup=advertEnabled&format=application%2Fjson

来自AWS,我间歇性地接收到以下错误:

代码语言:javascript
运行
复制
ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing: incorrect header check',))

示例:

代码语言:javascript
运行
复制
requests.get(url.format('832504'))
<Response [200]>
requests.get(url.format('460398'))
<Response [200]>
requests.get(url.format('27616'))
<Response [200]>
requests.get(url.format('23657'))
<Response [200]>
requests.get(url.format('8661'))
ContentDecodingError...
requests.get(url.format('14250'))
<Response [200]>
requests.get(url.format('516307'))
ContentDecodingError...
requests.get(url.format('10366'))
<Response [200]>

我尝试过不同的标题组合(包括这里的建议:https://github.com/requests/requests/issues/3849)和删除contentEncoding=gzip param (返回502状态代码)。

考虑到这个API在我的PC上完美无缺地工作,也许Vudu和AWS之间有一些冲突?

EN

回答 1

Stack Overflow用户

发布于 2020-09-05 03:00:37

我认为这是当前python请求库的限制(或设计行为,请参阅这里)。

因此,您必须使用resp.raw来获取原始字节。(Note:要访问resp.raw,还需要stream=True)。

代码语言:javascript
运行
复制
resp = session.get(url, stream=True)
data = resp.raw.read()
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53435774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档