Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16532 closed Cleanup/optimization (fixed)

Clearer explanation of how the test client expects HTTP headers to be passed

Reported by: rbanffy Owned by: nobody
Component: Documentation Version:
Severity: Normal Keywords: test http host headers
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

During tests (manage.py test), when I pass a "Host" header through the **extra kwarg (see https://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.get) to the get method of the test client, the request handler gets a request object whose get_host method returns "testserver" instead of the string I passed through the Host header. The string is available in request.METAHost?

Attachments (1)

patch_16532.txt (1.0 KB) - added by rbanffy 4 years ago.
Patch adding note on the CGI convention used in headers passed to the test client

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by rbanffy

Patch adding note on the CGI convention used in headers passed to the test client

comment:1 Changed 4 years ago by SmileyChris

  • Component changed from Testing framework to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from django.core.handlers.wsgi.WSGIRequest's get_host doesn't get "Host" header passed to django.test.client.Client.get to Clearer explanation of how the test client expects HTTP headers to be passed
  • Version 1.2 deleted

comment:2 Changed 4 years ago by SmileyChris

  • Has patch set
  • Type changed from Bug to Cleanup/optimization

comment:3 Changed 4 years ago by SmileyChris

  • Resolution set to fixed
  • Status changed from new to closed

In [16554]:

Fixes #16532 -- Clearer explanation of how the test client expects HTTP headers to be passed. Thanks for the patch, Ricardo Bánffy.

comment:4 Changed 4 years ago by SmileyChris

In [16555]:

[1.3.X] Fixes #16532 -- Clearer explanation of how the test client expects HTTP headers to be passed. Thanks for the patch, Ricardo Bánffy.

Backport of r16554 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top