Parse header strings in format 'Key: Value' into a dictionary.
(header_list: list[str])
| 273 | |
| 274 | |
| 275 | def parse_headers(header_list: list[str]) -> dict[str, str]: |
| 276 | """Parse header strings in format 'Key: Value' into a dictionary.""" |
| 277 | headers = {} |
| 278 | if not header_list: |
| 279 | return headers |
| 280 | |
| 281 | for header in header_list: |
| 282 | if ":" in header: |
| 283 | key, value = header.split(":", 1) |
| 284 | headers[key.strip()] = value.strip() |
| 285 | else: |
| 286 | print(f"Warning: Ignoring malformed header: {header}") |
| 287 | return headers |
| 288 | |
| 289 | |
| 290 | def parse_env_vars(env_list: list[str]) -> dict[str, str]: |