Skip to content

Commit

Permalink
v0.13.8 - Bugfix/proxy response with wrong content length (#42)
Browse files Browse the repository at this point in the history
* remove content-length if content-encoding is gzip
* v0.13.8
  • Loading branch information
zhaoye authored Oct 10, 2018
1 parent 893de87 commit aca695d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lyrebird/mock/handlers/proxy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ def handle(self, handler_context):
resp_headers = [('lyrebird', 'proxy')]
for name, value in r.headers.items():
# rm 'content-length' from ignore list
if name.lower() in ('connection',
'content-encoding',
if name.lower() in ('content-encoding',
'transfer-encoding'):
continue
if name.lower() == 'content-length' and 'content-encoding' in r.headers and r.headers['content-encoding']=='gzip':
# 如果是gzip请求,由于requests自动解压gzip,所以此处抹去content-length,以匹配解压后的数据长度
continue
resp_headers.append((name, value))

handler_context.request.url = origin_url
# After huangyuanzhen test, we use 2048byte buffer :D
handler_context.response = Response(
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (0, 13, 7)
IVERSION = (0, 13, 8)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit aca695d

Please sign in to comment.