Commit 10a5689c authored by Hanno Schlichting's avatar Hanno Schlichting

Update available HTTP response code, 302 is now called Found.

parent e4814857
......@@ -51,6 +51,8 @@ Bugs Fixed
Features Added
++++++++++++++
- Update available HTTP response code, 302 is now called Found.
- Add a new `runwsgi` script to serve PasteDeploy files.
- Depend on and automatically set up `five.globalrequest`.
......
......@@ -40,7 +40,7 @@ six==1.10.0
tempstorage==3.0
transaction==1.6.1
unittest2==1.1.0
zExceptions==3.0
zExceptions==3.2
zLOG==3.0
zc.lockfile==1.2.1
zdaemon==4.1.0
......
......@@ -78,7 +78,7 @@ setup(
'tempstorage',
'transaction',
'zdaemon',
'zExceptions',
'zExceptions >= 3.2',
'zLOG',
'zope.browser',
'zope.browsermenu',
......
......@@ -21,8 +21,7 @@ import httplib
import urllib2
import mechanize
import zope.publisher.http
from zExceptions import status_reasons
from zope.testbrowser import browser
from Testing.ZopeTestCase.zopedoctest import functional
......@@ -86,7 +85,7 @@ class PublisherConnection(object):
"""
real_response = self.response._response
status = real_response.getStatus()
reason = zope.publisher.http.status_reasons[real_response.status]
reason = status_reasons[real_response.status]
headers = []
# Convert header keys to camel case. This is basically a copy
# paste from ZPublisher.HTTPResponse
......
......@@ -24,8 +24,11 @@ from urllib import quote
import zlib
from zope.event import notify
from zExceptions import Redirect
from zExceptions import Unauthorized
from zExceptions import (
Redirect,
status_reasons,
Unauthorized,
)
from zExceptions.ExceptionFormatter import format_exception
from ZPublisher import BadRequest
from ZPublisher import InternalError
......@@ -42,56 +45,6 @@ default_encoding = 'utf-8'
# but a better solution is to make standard_error_message display error_tb.
APPEND_TRACEBACKS = 0
status_reasons = {
100: 'Continue',
101: 'Switching Protocols',
102: 'Processing',
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
207: 'Multi-Status',
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Moved Temporarily',
303: 'See Other',
304: 'Not Modified',
305: 'Use Proxy',
307: 'Temporary Redirect',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Time-out',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Large',
415: 'Unsupported Media Type',
416: 'Requested range not satisfiable',
417: 'Expectation Failed',
422: 'Unprocessable Entity',
423: 'Locked',
424: 'Failed Dependency',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Time-out',
505: 'HTTP Version not supported',
507: 'Insufficient Storage',
}
status_codes = {}
# Add mappings for builtin exceptions and
# provide text -> error code lookups.
......
......@@ -97,7 +97,7 @@ Handle zExceptions.Redirect.
>>> browser.open('http://localhost/test_folder_1_/foo')
Traceback (most recent call last):
...
HTTPError: HTTP Error 302: Moved Temporarily
HTTPError: HTTP Error 302: Found
>>> browser.contents
''
>>> browser.headers['Location']
......
......@@ -966,7 +966,7 @@ class HTTPResponseTests(unittest.TestCase):
response = self._makeOne()
response.redirect('http://example.com/')
status, headers = response.finalize()
self.assertEqual(status, '302 Moved Temporarily')
self.assertEqual(status, '302 Found')
self.assertEqual(headers,
[('X-Powered-By', 'Zope (www.zope.org), '
'Python (www.python.org)'),
......@@ -1170,7 +1170,7 @@ class HTTPResponseTests(unittest.TestCase):
result = str(response)
lines = result.split('\r\n')
self.assertEqual(len(lines), 6)
self.assertEqual(lines[0], 'Status: 302 Moved Temporarily')
self.assertEqual(lines[0], 'Status: 302 Found')
self.assertEqual(lines[1], 'X-Powered-By: Zope (www.zope.org), '
'Python (www.python.org)')
self.assertEqual(lines[2], 'Content-Length: 0')
......
......@@ -399,7 +399,7 @@ class Test_publish_module(unittest.TestCase):
app_iter = self._callFUT(environ, start_response, _publish)
self.assertEqual(app_iter, ('', ''))
(status, headers), kw = start_response._called_with
self.assertEqual(status, '302 Moved Temporarily')
self.assertEqual(status, '302 Found')
self.assertTrue(('Location', '/redirect_to') in headers)
self.assertTrue(('Content-Length', '0') in headers)
self.assertEqual(kw, {})
......
......@@ -328,7 +328,7 @@ class http_request:
206: "Partial Content",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Moved Temporarily",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
......
......@@ -28,7 +28,7 @@ class redirecting_handler:
part = m.group(1)
request['Location'] = self.redirect % part
request.error (302) # moved temporarily
request.error (302) # Found
def __repr__ (self):
return '<Redirecting Handler at %08x [%s => %s]>' % (
......
......@@ -248,7 +248,7 @@ class ZServerHTTPResponseTestCase(unittest.TestCase):
response._http_connection = 'keep-alive'
response.redirect('somewhere')
self._assertResponsesAreEqual(str(response),
('HTTP/1.1 302 Moved Temporarily',
('HTTP/1.1 302 Found',
'Content-Length: 0',
'Date: ...',
'Location: somewhere',
......
......@@ -43,7 +43,7 @@ zc.lockfile = 1.2.1
ZConfig = 3.1.0
zdaemon = 4.1.0
ZEO = 4.2.1
zExceptions = 3.0
zExceptions = 3.2
zLOG = 3.0
ZODB = 4.4.2
zodbpickle = 0.6.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment