[CalendarServer-changes] [11555] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 24 10:40:08 PDT 2013
Revision: 11555
http://trac.calendarserver.org//changeset/11555
Author: sagen at apple.com
Date: 2013-07-24 10:40:08 -0700 (Wed, 24 Jul 2013)
Log Message:
-----------
Use temporary redirects for the auth service
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/provision/root.py
CalendarServer/trunk/twext/web2/http.py
CalendarServer/trunk/twext/web2/test/test_http.py
Modified: CalendarServer/trunk/calendarserver/provision/root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/root.py 2013-07-24 15:52:48 UTC (rev 11554)
+++ CalendarServer/trunk/calendarserver/provision/root.py 2013-07-24 17:40:08 UTC (rev 11555)
@@ -310,7 +310,8 @@
host,
request.path
)
- )
+ ),
+ temporary=True
)
raise HTTPError(response)
Modified: CalendarServer/trunk/twext/web2/http.py
===================================================================
--- CalendarServer/trunk/twext/web2/http.py 2013-07-24 15:52:48 UTC (rev 11554)
+++ CalendarServer/trunk/twext/web2/http.py 2013-07-24 17:40:08 UTC (rev 11555)
@@ -213,12 +213,14 @@
"""
A L{Response} object that contains a redirect to another network location.
"""
- def __init__(self, location):
+ def __init__(self, location, temporary=False):
"""
@param location: the URI to redirect to.
+ @param temporary: whether it's a temporary redirect or permanent
"""
+ code = responsecode.TEMPORARY_REDIRECT if temporary else responsecode.MOVED_PERMANENTLY
super(RedirectResponse, self).__init__(
- responsecode.MOVED_PERMANENTLY,
+ code,
"Document moved to %s." % (location,)
)
Modified: CalendarServer/trunk/twext/web2/test/test_http.py
===================================================================
--- CalendarServer/trunk/twext/web2/test/test_http.py 2013-07-24 15:52:48 UTC (rev 11554)
+++ CalendarServer/trunk/twext/web2/test/test_http.py 2013-07-24 17:40:08 UTC (rev 11555)
@@ -17,6 +17,18 @@
from twext.web2.channel.http import SSLRedirectRequest, HTTPFactory
from twisted.internet.task import deferLater
+
+class RedirectResponseTestCase(unittest.TestCase):
+
+ def testTemporary(self):
+ """
+ Verify the "temporary" parameter sets the appropriate response code
+ """
+ req = http.RedirectResponse("http://example.com/", temporary=False)
+ self.assertEquals(req.code, responsecode.MOVED_PERMANENTLY)
+ req = http.RedirectResponse("http://example.com/", temporary=True)
+ self.assertEquals(req.code, responsecode.TEMPORARY_REDIRECT)
+
class PreconditionTestCase(unittest.TestCase):
def checkPreconditions(self, request, response, expectedResult, expectedCode,
**kw):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130724/85e3cd6e/attachment-0001.html>
More information about the calendarserver-changes
mailing list