[Django] #32397: django-admin start[project|app] doesn't send proper user agent header when HTTP(S) url is sent.

27 views
Skip to first unread message

Django

unread,
Jan 29, 2021, 8:48:13 PM1/29/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: New | Status: assigned
feature |
Component: Core | Version: 3.1
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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).

--
Ticket URL: <https://code.djangoproject.com/ticket/32397>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 29, 2021, 8:48:26 PM1/29/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: New feature | Status: assigned
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rsp2k):

* Attachment "add-user-agent-to-django-admin-templates.diff" added.

Django

unread,
Jan 29, 2021, 8:49:37 PM1/29/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: New feature | Status: assigned
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by rsp2k:

Old description:

> 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).

New description:

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:1>

Django

unread,
Jan 29, 2021, 8:51:05 PM1/29/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: New feature | Status: assigned
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rsp2k):

* Attachment "add-user-agent-to-django-admin-templates.diff" added.


Django

unread,
Jan 30, 2021, 8:08:37 AM1/30/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: (none)
Type: New feature | Status: new

Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rsp2k):

* owner: rsp2k => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:2>

Django

unread,
Feb 2, 2021, 2:16:30 AM2/2/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: (none)
Type: | Status: closed
Cleanup/optimization |

Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* type: New feature => Cleanup/optimization
* resolution: => needsinfo
* needs_tests: 0 => 1


Comment:

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 the
`StartProject` and `StartApp` classes.

If so can you add the tests, [https://github.com/django/django/pulls open
a PR on GitHub], re-open the ticket, and assign yourself again?
Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:3>

Django

unread,
Feb 2, 2021, 11:25:30 PM2/2/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: (none)
Type: | Status: new

Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rsp2k):

* status: closed => new
* resolution: needsinfo =>


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:4>

Django

unread,
Feb 2, 2021, 11:25:40 PM2/2/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: | Status: assigned

Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by rsp2k):

* owner: (none) => rsp2k
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:5>

Django

unread,
Feb 3, 2021, 1:12:38 AM2/3/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Super, thanks for the follow-up! Let's accept for review. Welcome aboard!

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:6>

Django

unread,
Nov 22, 2021, 8:38:36 AM11/22/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ad Timmering):

* cc: Ad Timmering (added)
* needs_tests: 1 => 0


Comment:

Have taken the liberty of adding tests to rsp2k's patch in this
[https://github.com/django/django/pull/15111 PR].

Feels like there should be a cleaner way to get the UA from the request;
ideas very welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:7>

Django

unread,
Nov 25, 2021, 5:07:50 AM11/25/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: rsp2k
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:8>

Django

unread,
Nov 25, 2021, 9:01:02 AM11/25/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: Ad
Type: | Timmering
Cleanup/optimization | Status: assigned

Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ad Timmering):

* owner: rsp2k => Ad Timmering
* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/15111 PR] updated reflecting
feedback, and rebased to main.

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:9>

Django

unread,
Nov 25, 2021, 2:46:19 PM11/25/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: Ad
Type: | Timmering
Cleanup/optimization | Status: assigned
Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:10>

Django

unread,
Nov 26, 2021, 12:22:41 AM11/26/21
to django-...@googlegroups.com
#32397: django-admin start[project|app] doesn't send proper user agent header when
HTTP(S) url is sent.
-------------------------------------+-------------------------------------
Reporter: rsp2k | Owner: Ad
Type: | Timmering
Cleanup/optimization | Status: closed

Component: Core (Management | Version: 3.1
commands) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9a6e2df3a8f01ea761529bec48e5a8dc0ea9575b" 9a6e2df3]:
{{{
#!CommitTicketReference repository=""
revision="9a6e2df3a8f01ea761529bec48e5a8dc0ea9575b"
Fixed #32397 -- Made startapp/startproject management commands set User-
Agent.

This sets User-Agent to 'Django/<version>'.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32397#comment:11>

Reply all
Reply to author
Forward
0 new messages