mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Preserve media-type parameters in Content-Type header
Use raw_content_type (with charset etc.) for the outgoing header,
normalized form only for dispatch matching.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ba8db8ccc3
commit
7c30184f3b
1 changed files with 6 additions and 4 deletions
|
|
@ -76,11 +76,13 @@ class RequestDirector:
|
|||
content: str | bytes | None = None
|
||||
|
||||
# Step 5: Determine the declared content type from the OpenAPI spec.
|
||||
# Strip parameters (e.g. "; charset=utf-8") for dispatch matching.
|
||||
# Use the raw value for outgoing Content-Type headers (preserves
|
||||
# parameters like charset), but normalize for dispatch matching.
|
||||
raw_content_type: str | None = None
|
||||
declared_content_type: str | None = None
|
||||
if route.request_body and route.request_body.content_schema:
|
||||
raw_ct = next(iter(route.request_body.content_schema))
|
||||
declared_content_type = raw_ct.split(";")[0].strip().lower()
|
||||
raw_content_type = next(iter(route.request_body.content_schema))
|
||||
declared_content_type = raw_content_type.split(";")[0].strip().lower()
|
||||
|
||||
# httpx requires cookie values to be strings; use OpenAPI-style
|
||||
# serialization (e.g. true/false for booleans, not True/False)
|
||||
|
|
@ -124,7 +126,7 @@ class RequestDirector:
|
|||
# sets application/json.
|
||||
content = _json.dumps(body, allow_nan=False).encode("utf-8")
|
||||
headers = dict(headers) if headers else {}
|
||||
headers["Content-Type"] = declared_content_type
|
||||
headers["Content-Type"] = raw_content_type
|
||||
else:
|
||||
json_body = body
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue