Skip to content

Commit

Permalink
RUMM-1679 Decode deflated http body
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Oct 6, 2021
1 parent a8989d2 commit d0c7231
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import time
import base64
import zlib

# If `--prefer-localhost` argument is set, the server will listen on http://127.0.0.1:8000.
# By default it tries to discover private IP address on local network and uses localhost as fallback.
Expand Down Expand Up @@ -55,6 +56,11 @@ def __POST_any(self, parameters):
global history
request_path = parameters[0]
request_body = self.rfile.read(int(self.headers['Content-Length']))

# Decompress 'deflate' encoded body
if 'Content-Encoding' in self.headers and self.headers['Content-Encoding'] == 'deflate':
request_body = zlib.decompress(request_body)

request = GenericRequest("POST", request_path, self.headers, request_body)
history.add_request(request)
return "{}"
Expand Down Expand Up @@ -105,7 +111,7 @@ def __init__(self, http_method, path, http_headers, http_body):
self.path = path
self.http_method = http_method
self.http_headers = http_headers
self.http_body = http_body
self.http_body = http_body

class GenericRequestsHistory:
"""
Expand Down

0 comments on commit d0c7231

Please sign in to comment.