mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
Merge dabfae7489 into 3b8ad37296
This commit is contained in:
commit
ce160e8ac0
2 changed files with 27 additions and 1 deletions
|
|
@ -7111,10 +7111,16 @@ class StandardLoggingPayloadSetup:
|
|||
request_headers: Final = cast( # cast-ok: request headers are untyped framework data
|
||||
dict[str, str], headers
|
||||
)
|
||||
lowercased_request_headers: Final[Mapping[str, str]] = MappingProxyType(
|
||||
{
|
||||
request_header_name.lower(): request_header_value
|
||||
for request_header_name, request_header_value in request_headers.items()
|
||||
}
|
||||
)
|
||||
|
||||
header_tags: Final = []
|
||||
for header_name in extra_headers:
|
||||
header_value = request_headers.get(header_name)
|
||||
header_value = lowercased_request_headers.get(header_name.lower())
|
||||
if header_value:
|
||||
header_tags.append(f"{header_name}: {header_value}")
|
||||
|
||||
|
|
|
|||
|
|
@ -3672,6 +3672,26 @@ def test_get_extra_header_tags():
|
|||
delattr(litellm, "extra_spend_tag_headers")
|
||||
|
||||
|
||||
def test_get_extra_header_tags_matches_headers_case_insensitively():
|
||||
"""Header field names are case-insensitive (RFC 9110 section 5.1), so a
|
||||
request header must become a spend tag even when its casing differs from
|
||||
the extra_spend_tag_headers config entry."""
|
||||
with patch.object(litellm, "extra_spend_tag_headers", ["x-customer-id", "X-Session-ID"], create=True):
|
||||
tags = StandardLoggingPayloadSetup._get_extra_header_tags(
|
||||
proxy_server_request={
|
||||
"headers": {
|
||||
"X-Customer-Id": "cust_98765",
|
||||
"x-session-id": "sess_123",
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
assert tags == [
|
||||
"x-customer-id: cust_98765",
|
||||
"X-Session-ID: sess_123",
|
||||
]
|
||||
|
||||
|
||||
def test_response_cost_calculator_with_response_cost_in_hidden_params(logging_obj):
|
||||
from litellm import Router
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue