honor x-www-form-urlencoded in http block (#4232)
This commit is contained in:
@@ -291,7 +291,7 @@ class Settings(BaseSettings):
|
|||||||
# GEMINI
|
# GEMINI
|
||||||
GEMINI_API_KEY: str | None = None
|
GEMINI_API_KEY: str | None = None
|
||||||
GEMINI_INCLUDE_THOUGHT: bool = False
|
GEMINI_INCLUDE_THOUGHT: bool = False
|
||||||
GEMINI_THINKING_BUDGET: int | None = 500
|
GEMINI_THINKING_BUDGET: int | None = None
|
||||||
|
|
||||||
# VERTEX_AI
|
# VERTEX_AI
|
||||||
VERTEX_CREDENTIALS: str | None = None
|
VERTEX_CREDENTIALS: str | None = None
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ async def aiohttp_request(
|
|||||||
method: str,
|
method: str,
|
||||||
url: str,
|
url: str,
|
||||||
headers: dict[str, str] | None = None,
|
headers: dict[str, str] | None = None,
|
||||||
|
*,
|
||||||
|
body: dict[str, Any] | str | None = None,
|
||||||
data: dict[str, Any] | None = None,
|
data: dict[str, Any] | None = None,
|
||||||
json_data: dict[str, Any] | None = None,
|
json_data: dict[str, Any] | None = None,
|
||||||
cookies: dict[str, str] | None = None,
|
cookies: dict[str, str] | None = None,
|
||||||
@@ -39,10 +41,17 @@ async def aiohttp_request(
|
|||||||
|
|
||||||
# Handle body based on content type and method
|
# Handle body based on content type and method
|
||||||
if method.upper() != "GET":
|
if method.upper() != "GET":
|
||||||
|
# Explicit overrides first
|
||||||
if json_data is not None:
|
if json_data is not None:
|
||||||
request_kwargs["json"] = json_data
|
request_kwargs["json"] = json_data
|
||||||
elif data is not None:
|
elif data is not None:
|
||||||
request_kwargs["data"] = data
|
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:
|
async with session.request(method.upper(), **request_kwargs) as response:
|
||||||
response_headers = dict(response.headers)
|
response_headers = dict(response.headers)
|
||||||
|
|||||||
@@ -3891,7 +3891,7 @@ class HttpRequestBlock(Block):
|
|||||||
method=self.method,
|
method=self.method,
|
||||||
url=self.url,
|
url=self.url,
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
json_data=self.body,
|
body=self.body,
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
follow_redirects=self.follow_redirects,
|
follow_redirects=self.follow_redirects,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user