Keep a pg_net token when a request sets its own User-Agent
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c, postgresql
- Domain
- backend, networking
Research direction
Start in init_curl_handle in src/core.c and review how caller headers and the default CURLOPT_USERAGENT are added. Then read the User-Agent cases in test/test_http_headers.py. Done means requests with a caller-supplied User-Agent send one header with the caller value first and the pg_net version token appended, while requests without one retain the existing default.
Written by the indexing model from the issue text.
Description
Follow-up to #322 / #323.
Since #323, a User-Agent set in headers replaces the default completely, so the request no longer says it came from pg_net:
select net.http_get(
url := 'http://localhost:8080/headers',
headers := '{"User-Agent": "my-app/1.0"}'
);
User-Agent: my-app/1.0
#323 was right to stop sending two User-Agent headers. This issue proposes keeping the single header but adding pg_net to the end of the caller's value, instead of dropping it.
Proposed behavior
A User-Agent may list several product tokens, most important first (RFC 9110 §10.1.5). pg_net could add its own token after the caller's:
User-Agent: my-app/1.0 pg_net/0.20.4
- Requests without a
User-Agentkeep sendingUser-Agent: pg_net/<version>, as they do today. - There is still exactly one
User-Agentheader, so #322 stays fixed. - The caller's token stays first, so servers that look at the first product still see the caller's app.
Why
Operators who receive pg_net traffic (API providers, webhook receivers, abuse and security teams) use the User-Agent to tell which client sent a request. When requests carry no pg_net token, they can't tell pg_net traffic apart from other clients, for example when triaging unexpected or abusive outbound requests from a database. Clients such as the AWS CLI and SDKs (aws-cli/2.x Python/3.x ...) and browsers use the same multi-token convention.
Possible implementation
In init_curl_handle (src/core.c), while building the request header list, find a caller-supplied User-Agent (any letter case) and rewrite it as <caller value> pg_net/<EXTVERSION>. If there isn't one, keep the CURLOPT_USERAGENT default added in #323. The tests in test/test_http_headers.py would need to change to expect the appended token.
If a fully caller-controlled User-Agent is something users rely on, an opt-out setting could keep the #323 behaviour, but I'd suggest appending by default.
- Dominant language
- Python
- Stars
- 376
- Forks
- 44
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/pg_net
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
supabase/pg_net#235 · 1 comment ·
Maintainers usually reply within 2 days
-
idea
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
supabase/pg_net#159 · 1 reaction ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
supabase/pg_net#321 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
supabase/pg_net#320 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ANCORATE/EncryptHome#8 ·
-
PluginProvider.storeInstance races and clobbers the dedup cache for concurrent loadsPossibly taken @Wilson0511 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 2 days
-
Bug: failed Together chat calls do not record operation duration or error.typePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
community documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100