Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: handle mock Content-Length headers in safe_requests

LearningCircuitbff017c4d124
diff --git a/src/local_deep_research/utils/safe_requests.py b/src/local_deep_research/utils/safe_requests.py
index 72baf6e747..73c581b7e5 100644
--- a/src/local_deep_research/utils/safe_requests.py
+++ b/src/local_deep_research/utils/safe_requests.py
@@ -60,11 +60,16 @@ def safe_get(
# Check response size
content_length = response.headers.get("Content-Length")
- if content_length and int(content_length) > MAX_RESPONSE_SIZE:
- raise ValueError(
- f"Response too large: {content_length} bytes "
- f"(max {MAX_RESPONSE_SIZE})"
- )
+ if content_length:
+ try:
+ if int(content_length) > MAX_RESPONSE_SIZE:
+ raise ValueError(
+ f"Response too large: {content_length} bytes "
+ f"(max {MAX_RESPONSE_SIZE})"
+ )
+ except (ValueError, TypeError):
+ # Ignore if Content-Length is not a valid number (e.g., in mocks)
+ pass
return response
@@ -120,11 +125,16 @@ def safe_post(
# Check response size
content_length = response.headers.get("Content-Length")
- if content_length and int(content_length) > MAX_RESPONSE_SIZE:
- raise ValueError(
- f"Response too large: {content_length} bytes "
- f"(max {MAX_RESPONSE_SIZE})"
- )
+ if content_length:
+ try:
+ if int(content_length) > MAX_RESPONSE_SIZE:
+ raise ValueError(
+ f"Response too large: {content_length} bytes "
+ f"(max {MAX_RESPONSE_SIZE})"
+ )
+ except (ValueError, TypeError):
+ # Ignore if Content-Length is not a valid number (e.g., in mocks)
+ pass
return response