Skip to content

Commit

Permalink
fix: Avoid exception on empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Dec 15, 2024
1 parent 0850089 commit b325b39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions har2tree/har2tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ def make_tree(self) -> URLNode:
if self.har.downloaded_filename and self.har.downloaded_file:
downloaded_file = (self.har.downloaded_filename if self.har.downloaded_filename else '',
self.har.downloaded_file if self.har.downloaded_file else None)

self.rendered_node.add_rendered_features(list(self.all_url_requests.keys()),
rendered_html=self.har.html_content if self.har.html_content else None,
downloaded_file=downloaded_file)
if not self.rendered_node.empty_response:
self.rendered_node.add_rendered_features(list(self.all_url_requests.keys()),
rendered_html=self.har.html_content if self.har.html_content else None,
downloaded_file=downloaded_file)

# Initialize the hostname tree root
self.hostname_tree.add_url(self.url_tree)
Expand Down
1 change: 1 addition & 0 deletions har2tree/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def load_har_entry(self, har_entry: MutableMapping[str, Any], all_requests: list
if not self.response['content'].get('text') or self.response['content']['text'] == '':
# If the content of the response is empty, skip.
self.add_feature('empty_response', True)
self.add_feature('mimetype', 'inode/x-empty')
else:
self.add_feature('empty_response', False)
if self.response['content'].get('encoding') == 'base64':
Expand Down

0 comments on commit b325b39

Please sign in to comment.