[FEATURE] Configure HTTP User-Agent - #86
Open
reubano wants to merge 2 commits into
Open
Conversation
reubano
force-pushed
the
feat/configurable-user-agent
branch
from
September 3, 2026 21:47
b376832 to
4bc0f84
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It’s a cross-cutting change affecting multiple sync/async HTTP entry points and generated config layers, and it also depends on stacked behavior from #84.
Pull request overview
Adds an optional per-pipe user_agent override to Riko’s HTTP-capable pipes while preserving the default riko/<version> policy (as established by the stacked #84), and propagates that value through both sync (requests/urllib) and async (httpx/anyio) fetch paths.
Changes:
- Introduces
user_agentas shared configuration across URL-fetching source pipes (andexchangerate) and wires it through their sync/async parsers. - Extends the async HTTP utilities (
async_get,async_url_open,async_url_read, and RSS discovery) to accept and apply the resolved User-Agent. - Adds internal tests covering async User-Agent resolution and propagation through
fetchpage, plus syncFetch(...)header forwarding.
File summaries
| File | Description |
|---|---|
| tests/internal/test_user_agent.py | Adds contract tests for custom/default User-Agent resolution and pipe forwarding. |
| riko/types/modules.py | Adds shared user_agent fields to relevant TypedDict conf contracts via _Http* bases. |
| riko/types/_configs.py | Regenerates parse-time Objconf types to include user_agent for affected modules. |
| riko/modules/xpathfetchpage.py | Forwards user_agent into sync/async URL open paths and documents the option. |
| riko/modules/fetchtext.py | Forwards user_agent into sync/async URL open paths and documents the option. |
| riko/modules/fetchtable.py | Forwards user_agent into sync/async URL open paths and documents the option. |
| riko/modules/fetchsitefeed.py | Propagates user_agent through RSS autodiscovery and subsequent feed fetch. |
| riko/modules/fetchpage.py | Forwards user_agent into sync Fetch and async async_url_read, updates docs. |
| riko/modules/fetchdata.py | Forwards user_agent into sync Fetch and async URL open paths, updates docs. |
| riko/modules/fetch.py | Propagates user_agent into feed fetching/parsing for sync and async paths. |
| riko/modules/feedautodiscovery.py | Propagates user_agent into RSS autodiscovery (sync + async). |
| riko/modules/exchangerate.py | Applies user_agent to both httpx (async_get) and sync Fetch request paths. |
| riko/modules/csv.py | Forwards user_agent into sync/async URL open paths and documents the option. |
| riko/bado/io.py | Adds user_agent plumbing to async URL helpers so httpx requests use the resolved UA. |
| riko/bado/_util.py | Adds user_agent to async_get and applies it via request headers (httpx). |
| riko/autorss.py | Adds user_agent to RSS discovery helpers and forwards into underlying fetch. |
| riko/_io.py | Adds shared resolve_user_agent() and uses it in sync HTTP opener headers. |
Review details
- Files reviewed: 17/17 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+123
to
+125
| def resolve_user_agent(user_agent: str | None = None) -> str: | ||
| """Uses an explicit user agent or falls back to riko's default.""" | ||
| return user_agent if user_agent is not None else default_user_agent() |
reubano
force-pushed
the
feat/configurable-user-agent
branch
from
September 3, 2026 22:00
97aa870 to
3212f83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #12.
Stacked on #84. #84 establishes
riko/<version>as the default HTTP User-Agent; this PR adds an optional per-pipeuser_agentoverride while preserving that default when unset.This PR:
user_agentconfiguration to URL-fetching source pipes andexchangerate;Dependency
This PR targets
fix/default-user-agentand should merge after #84. Once #84 lands infeatures, this PR can be retargeted tofeaturesso only the #12 delta remains.Commits
[TEST] Cover configurable HTTP user agent[FEATURE] Configure HTTP user agent