#16040: test.Client does not handle domain changes on redirection follow
---------------------------------------+-------------------------------
               Reporter:  jdunck       |          Owner:  nobody
                   Type:  New feature  |         Status:  new
              Milestone:               |      Component:  Uncategorized
                Version:  1.3          |       Severity:  Normal
             Resolution:               |       Keywords:
           Triage Stage:  Unreviewed   |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  0
---------------------------------------+-------------------------------
Description changed by jdunck:

Old description:

> The default SERVER_NAME used by the test client is testserver.
>
> I have a multi-tenant site serving www.foo.com and www.bar.com.  I also
> have a view which redirects from /spam/ to /eggs/.
>
> Middleware handles the www -> m redirection, while a view handles the
> /spam/ -> /eggs/ redirection.
>
> If the test client requests http://www.foo.com/spam/, it is redirected to
> http://www.bar.com/spam/, but _handle_redirects, while parsing url into
> scheme and path, does not also update SERVER_NAME in extras.  This causes
> the 2nd request handling to be handled as though it were for
> http://www.foo.com/spam/ (again), causing a redirection loop.
>
> I think that just as wsgi.url_scheme is updated for scheme,
> extra['SERVER_NAME'] should be updated for netloc.
>
> It's debatable to me whether this is a bug or a feature -- I realize
> multi-tenancy is relatively unusual under Django.

New description:

 The default SERVER_NAME used by the test client is testserver.

 I have a multi-tenant site serving www.foo.com and www.bar.com.  I also
 have a view which redirects from /spam/ to /eggs/.

 Middleware handles the domain redirection, while a view handles the /spam/
 -> /eggs/ redirection.

 If the test client requests http://www.foo.com/spam/, it is redirected to
 http://www.bar.com/spam/, but _handle_redirects, while parsing url into
 scheme and path, does not also update SERVER_NAME in extras.  This causes
 the 2nd request handling to be handled as though it were for
 http://www.foo.com/spam/ (again), causing a redirection loop.

 I think that just as wsgi.url_scheme is updated for scheme,
 extra['SERVER_NAME'] should be updated for netloc.

 It's debatable to me whether this is a bug or a feature -- I realize
 multi-tenancy is relatively unusual under Django.

--

-- 
Ticket URL: <http://code.djangoproject.com/ticket/16040#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to