Skip to content

Commit

Permalink
Bugfix/fix response null error (#885)
Browse files Browse the repository at this point in the history
* fix post process error when response data is empty

* ensure data not exist

---------

Co-authored-by: noO0ob <[email protected]>
  • Loading branch information
noO0oOo0ob and noO0ob authored Dec 24, 2024
1 parent 93d9594 commit 4b406f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lyrebird/mock/handlers/flow_editor_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def on_response_handler(self, handler_context):
handler_context.flow['response']['code'] = 200
if not handler_context.flow['response'].get('headers'):
handler_context.flow['response']['headers'] = {}
if not handler_context.flow['response'].get('data'):
if 'data' not in handler_context.flow['response']:
if handler_context.response:
handler_context.update_response_data2flow()
else:
Expand Down
4 changes: 3 additions & 1 deletion lyrebird/mock/handlers/handler_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ def update_client_resp_time(self):
resp_data = self.flow['response'].get('data', '')
if isinstance(resp_data, str):
self.flow['size'] = len(resp_data.encode())
else:
elif resp_data:
self.flow['size'] = len(resp_data)
else:
self.flow['size'] = 0

self.flow['duration'] = self.server_resp_time - self.client_req_time

Expand Down

0 comments on commit 4b406f8

Please sign in to comment.