I've got a Django project set up behind an Apache SSL listener on port
443. Unfortunately, this seems to break HTTP redirects.
For example, I have one view like this:
"""
@login_required
def home(request):
return HttpResponseRedirect('/user/%s/' % request.user)
"""
When a user hits this view, HTTP request/response headers go like
this:
"""
https://www.${DOMAIN}.com/user/home/
GET /user/home/ HTTP/1.1
Host: www.${DOMAIN}.com:443
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/
2009011218 Gentoo Firefox/3.0.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: sessionid=e81f501da88277eb901df1aa3d3aa454
HTTP/1.x 302 Found
Date: Mon, 19 Jan 2009 23:37:18 GMT
Server: JWS 1.3
Served-By: Joyent
Vary: Cookie,Accept-Encoding
Content-Type: text/html; charset=utf-8
Location: http://www.${DOMAIN}.com:443/user/${USER}/
Via: 1.1 ${DOMAIN}.com
Content-Encoding: gzip
Content-Length: 20
Connection: close
"""
Now, all the other browsers I've tried seem to be smart enough to
guess that if it's port 443, then maybe they should try SSL, but for
some reason Firefox gets its panties all in a bunch, sits down in a
huff, and throws this error:
"""
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Hint: https://${DOMAIN}.com/
"""
I certainly don't want to hard-code the domain name into my view
above. I'm trying to pick through the source in django.http, but I'm
not the sharpest knife in the drawer. Is it true that Django is
constructing HttpResponseRedirects with http:// URLs rather than https://
? Is there someway I can change this behavior, or troubleshoot the
actual source of the problem, or another way to accomplish my goal?
TIA
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---