The test client doesn't currently provide the HTTP_HOST header by
default. It does provide the SERVER_NAME header, because that header
is required as part of the WSGI spec:
http://www.python.org/dev/peps/pep-0333/
> I tried instantiating the Client with and without the HTTP_HOST
> argument, but both generate the error. Is the standard response meta
> data shown at http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.META
> not supported for the test client? If it is supported, how can I
> ensure the response contains this meta data?
If you read the docs on HttpRequest more closely, you will see that
they note that the headers that are available depend on the client and
the server. HTTP_HOST is not guaranteed to be available.
However, if you want to inject HTTP_HOST into the requests made by the
test client, you should be able to do so - either using arguments to
the client at time of construction:
>>> c = Client(HTTP_HOST='example.com')
or by manipulating the defaults of an existing test client:
>>> client.defaults = {'HTTP_HOST':'example.com'}
or by providing an 'extra' argument to an individual request:
>>> client.get('/foo/bar/',extra={'HTTP_HOST':'example.com'}
If any of these approaches aren't working for you, you will need to
tell us the error you are seeing before we can help.
Yours,
Russ Magee %-)