(response: Response)
| 48 | total_size_bytes = 0 |
| 49 | |
| 50 | def handle_response(response: Response): |
| 51 | nonlocal total_size_bytes |
| 52 | try: |
| 53 | # First try content-length header |
| 54 | content_length = response.headers.get("content-length") |
| 55 | if content_length: |
| 56 | total_size_bytes += int(content_length) |
| 57 | else: |
| 58 | # If that fails, read the body (expensive for large files) |
| 59 | body = response.body() |
| 60 | total_size_bytes += len(body) |
| 61 | except Exception as ex: |
| 62 | print(f"Error calculating size of web assets: {ex}") |
| 63 | |
| 64 | # Register the response handler |
| 65 | page.on("response", handle_response) |
nothing calls this directly
no test coverage detected
searching dependent graphs…