Convert to headers dictionary for HTTP forwarding with proper case.
Source code in ccproxy/plugins/claude_api/models.py
| def to_headers_dict(self) -> dict[str, str]:
"""Convert to headers dictionary for HTTP forwarding with proper case."""
headers = {}
# Map field names to proper HTTP header names
header_mapping = {
"anthropic_beta": "anthropic-beta",
"anthropic_version": "anthropic-version",
"anthropic_dangerous_direct_browser_access": "anthropic-dangerous-direct-browser-access",
"x_app": "x-app",
"user_agent": "User-Agent",
"x_stainless_lang": "X-Stainless-Lang",
"x_stainless_retry_count": "X-Stainless-Retry-Count",
"x_stainless_timeout": "X-Stainless-Timeout",
"x_stainless_package_version": "X-Stainless-Package-Version",
"x_stainless_os": "X-Stainless-OS",
"x_stainless_arch": "X-Stainless-Arch",
"x_stainless_runtime": "X-Stainless-Runtime",
"x_stainless_runtime_version": "X-Stainless-Runtime-Version",
}
for field_name, header_name in header_mapping.items():
value = getattr(self, field_name, None)
if value is not None:
headers[header_name] = value
return headers
|