The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: sync redirect bypass, Host header port, redirect loop dead code
user00b25d6ca4f5
diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.pyindex 489a56daf8e..03d2af72329 100644--- a/litellm/llms/custom_httpx/http_handler.py+++ b/litellm/llms/custom_httpx/http_handler.py@@ -1019,6 +1019,7 @@ class HTTPHandler:url,params=params,headers=headers,+ follow_redirects=_follow_redirects,)return responsediff --git a/litellm/proxy/common_utils/url_utils.py b/litellm/proxy/common_utils/url_utils.pyindex f18378f9007..a47d7ae2ca4 100644--- a/litellm/proxy/common_utils/url_utils.py+++ b/litellm/proxy/common_utils/url_utils.py@@ -87,6 +87,11 @@ def validate_url(url: str) -> Tuple[str, str]:port = parsed.portdefault_port = 443 if parsed.scheme == "https" else 80+ # Build the Host header value — include port when non-default+ host_header = (+ hostname if (port is None or port == default_port) else f"{hostname}:{port}"+ )+# Resolve hostname and validate ALL addressestry:addrinfo = socket.getaddrinfo(@@ -113,7 +118,7 @@ def validate_url(url: str) -> Tuple[str, str]:# we rewrite to the validated IP like HTTP.ssl_verify = getattr(litellm, "ssl_verify", True)if parsed.scheme == "https" and ssl_verify is not False:- return url, hostname+ return url, host_header# For HTTP, rewrite URL to connect to the validated IP directly# to prevent DNS rebinding (no TLS to bind the connection).@@ -130,7 +135,7 @@ def validate_url(url: str) -> Tuple[str, str]:(parsed.scheme, new_netloc, parsed.path, parsed.params, parsed.query, ""))- return rewritten, hostname+ return rewritten, host_header_MAX_REDIRECTS = 10