Parses the HAR file and returns a dictionary mapping Request objects to response dictionaries.
(har_file_path: str)
| 90 | |
| 91 | |
| 92 | def 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 | |
| 115 | def build_url_to_req_res_map(req_res_dict: Dict[Request, Dict[str, str]]) -> Dict[str, Dict[str, Any]]: |
no test coverage detected