honor x-www-form-urlencoded in http block (#4232)

This commit is contained in:
Marc Kelechava
2025-12-08 17:34:08 -08:00
committed by GitHub
parent ffa980f1ff
commit 5e3211afac
3 changed files with 11 additions and 2 deletions

View File

@@ -291,7 +291,7 @@ class Settings(BaseSettings):
# GEMINI
GEMINI_API_KEY: str | None = None
GEMINI_INCLUDE_THOUGHT: bool = False
GEMINI_THINKING_BUDGET: int | None = 500
GEMINI_THINKING_BUDGET: int | None = None
# VERTEX_AI
VERTEX_CREDENTIALS: str | None = None

View File

@@ -14,6 +14,8 @@ async def aiohttp_request(
method: str,
url: str,
headers: dict[str, str] | None = None,
*,
body: dict[str, Any] | str | None = None,
data: dict[str, Any] | None = None,
json_data: dict[str, Any] | None = None,
cookies: dict[str, str] | None = None,
@@ -39,10 +41,17 @@ async def aiohttp_request(
# Handle body based on content type and method
if method.upper() != "GET":
# Explicit overrides first
if json_data is not None:
request_kwargs["json"] = json_data
elif data is not None:
request_kwargs["data"] = data
elif body is not None:
content_type = (headers or {}).get("Content-Type") or (headers or {}).get("content-type") or ""
if "application/x-www-form-urlencoded" in content_type.lower():
request_kwargs["data"] = body
else:
request_kwargs["json"] = body
async with session.request(method.upper(), **request_kwargs) as response:
response_headers = dict(response.headers)

View File

@@ -3891,7 +3891,7 @@ class HttpRequestBlock(Block):
method=self.method,
url=self.url,
headers=self.headers,
json_data=self.body,
body=self.body,
timeout=self.timeout,
follow_redirects=self.follow_redirects,
)