fix: send explicit User-Agent (Cloudflare 403s default Python-urllib UA at id.shre.ai)
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
2077591755
commit
16d6a30c04
Binary file not shown.
@@ -64,6 +64,8 @@ def http_json(method, url, headers=None, body=None, form=None, timeout=30):
|
||||
"""Returns (status, parsed-json-or-{'raw': text})."""
|
||||
data = None
|
||||
hdrs = dict(headers or {})
|
||||
# Cloudflare in front of id.shre.ai 403s the default Python-urllib UA.
|
||||
hdrs.setdefault("User-Agent", f"granthi-sync/{VERSION}")
|
||||
if form is not None:
|
||||
data = urllib.parse.urlencode(form).encode()
|
||||
hdrs.setdefault("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
Binary file not shown.
@@ -69,6 +69,8 @@ def http_json(method, url, headers=None, body=None, timeout=20):
|
||||
"""Minimal JSON-over-HTTP helper. Returns (status, parsed_or_text)."""
|
||||
data = None
|
||||
hdrs = dict(headers or {})
|
||||
# Cloudflare in front of id.shre.ai 403s the default Python-urllib UA.
|
||||
hdrs.setdefault("User-Agent", f"granthi-link/{VERSION}")
|
||||
if body is not None:
|
||||
data = json.dumps(body).encode()
|
||||
hdrs.setdefault("Content-Type", "application/json")
|
||||
|
||||
Reference in New Issue
Block a user