Skip to content

Commit a386e99

Browse files
Yogesh NaikYogesh Naik
authored andcommitted
Skipped Transfer-Encoding header
1 parent 8a6d2c5 commit a386e99

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

servirtium/recorder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ def process_request(self, request_body):
146146
ctt = str(response.content, 'utf-8').replace("https://todo-backend-sinatra.herokuapp.com", "http://localhost:61417") \
147147
.replace("todo-backend-sinatra.herokuapp.com", "localhost:61417").encode("utf-8")
148148

149+
self.send_header("Content-Length", str(len(ctt)))
149150
for name, value in sorted(response.headers.items()):
150-
if name == "Content-Length":
151-
value = str(len(ctt))
152-
153151
value = value.replace("https://todo-backend-sinatra.herokuapp.com", "http://localhost:61417")\
154152
.replace("todo-backend-sinatra.herokuapp.com", "localhost:61417")
155153

156-
self.send_header(name, value)
154+
if name != 'Transfer-Encoding': # skip Transfer-Encoding as we are setting Content-Length
155+
self.send_header(name, value)
156+
157157
self.end_headers()
158158
self.wfile.write(response.content)
159159
rsp_body = str(response.content, encoding='utf-8')

0 commit comments

Comments
 (0)