Opened 13 years ago

Closed 13 years ago

Last modified 13 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 13 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)

by rbanffy, 13 years ago

Attachment: patch_16532.txt added

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

comment:1 by Chris Beaven, 13 years ago

Component: Testing frameworkDocumentation
Summary: django.core.handlers.wsgi.WSGIRequest's get_host doesn't get "Host" header passed to django.test.client.Client.getClearer explanation of how the test client expects HTTP headers to be passed
Version: 1.2

comment:2 by Chris Beaven, 13 years ago

Has patch: set
Type: BugCleanup/optimization

comment:3 by Chris Beaven, 13 years ago

Resolution: fixed
Status: newclosed

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 by Chris Beaven, 13 years ago

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