MCPcopy Create free account
hub / github.com/Integuru-AI/Integuru / parse_har_file

Function parse_har_file

integuru/util/har_processing.py:92–112  ·  view source on GitHub ↗

Parses the HAR file and returns a dictionary mapping Request objects to response dictionaries.

(har_file_path: str)

Source from the content-addressed store, hash-verified

90
91
92def parse_har_file(har_file_path: str) -> Dict[Request, Dict[str, str]]:
93 """
94 Parses the HAR file and returns a dictionary mapping Request objects to response dictionaries.
95 """
96 req_res_dict = {}
97
98 with open(har_file_path, 'r', encoding='utf-8') as file:
99 har_data = json.load(file)
100
101 entries = har_data.get("log", {}).get("entries", [])
102
103 for entry in entries:
104 request_data = entry.get("request", {})
105 response_data = entry.get("response", {})
106
107 formatted_request = format_request(request_data)
108 response_dict = format_response(response_data)
109
110 req_res_dict[formatted_request] = response_dict
111
112 return req_res_dict
113
114
115def build_url_to_req_res_map(req_res_dict: Dict[Request, Dict[str, str]]) -> Dict[str, Dict[str, Any]]:

Callers 1

__init__Method · 0.85

Calls 2

format_requestFunction · 0.85
format_responseFunction · 0.85

Tested by

no test coverage detected