Opened 4 years ago
Closed 3 years ago
#32397 closed Cleanup/optimization (fixed)
django-admin start[project|app] doesn't send proper user agent header when HTTP(S) url is sent.
Reported by: | rsp2k | Owned by: | Ad Timmering |
---|---|---|---|
Component: | Core (Management commands) | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | Ad Timmering | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
By default, when fetching a remote template, django-admin start[app|project] uses the default urllib User Agent which causes some sites to block requests (namely gitlab, since they use cloudflare See https://gitlab.com/gitlab-org/gitlab/-/issues/219669).
This patch sets the 'User Agent' header to Django/DJANGO_VERSION.
Attachments (1)
Change History (12)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
by , 4 years ago
Attachment: | add-user-agent-to-django-admin-templates.diff added |
---|
comment:2 by , 4 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:3 by , 4 years ago
Needs tests: | set |
---|---|
Resolution: | → needsinfo |
Status: | new → closed |
Type: | New feature → Cleanup/optimization |
comment:4 by , 4 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Thank you for your reply. I am working on the tests now and will follow the steps you outlined.
I took myself off the ticket because I thought it might not get routed properly, my mistake. I'm reassigning it now.
comment:5 by , 4 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:6 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Super, thanks for the follow-up! Let's accept for review. Welcome aboard!
comment:7 by , 3 years ago
Cc: | added |
---|---|
Needs tests: | unset |
Have taken the liberty of adding tests to rsp2k's patch in this PR.
Feels like there should be a cleaner way to get the UA from the request; ideas very welcome.
comment:8 by , 3 years ago
Patch needs improvement: | set |
---|
comment:9 by , 3 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | unset |
PR updated reflecting feedback, and rebased to main.
comment:10 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Hi rsp2k.
I'm inclined to accept this — no problem setting the User-Agent.
Initially though I'm going to close as
needsinfo
— that info being, are you up for finishing this?I see you removed your assignment, but the patch needs tests. Specifically they could go in
django/tests/admin_scripts/tests.py
in theStartProject
andStartApp
classes.If so can you add the tests, open a PR on GitHub, re-open the ticket, and assign yourself again?
Thanks.