Commit 7931f353 authored by Martijn Pieters's avatar Martijn Pieters

Add a 'method' key to the HTTPRequest.other, containing the uppercased...

Add a 'method' key to the HTTPRequest.other, containing the uppercased REQUEST_METHOD. This makes HTTPRequest a little bit more compatible with Zope3 IHTTPRequest.
parent 7bf5316c
......@@ -331,6 +331,7 @@ class HTTPRequest(BaseRequest):
if script: script="%s/%s" % (server_url,script)
else: script=server_url
other['URL']=self.script=script
other['method'] = environ.get('REQUEST_METHOD', 'GET').upper()
################################################################
# Cookie values should *not* be appended to existing form
......
......@@ -740,6 +740,25 @@ class RequestTests( unittest.TestCase ):
self.assertEqual(getDebug(request), '1')
self.assert_(isinstance(getDebugFromZope3(request), DebugFlags))
def testMethod(self):
TEST_ENVIRON = {
'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '80',
}
from StringIO import StringIO
from ZPublisher.HTTPRequest import HTTPRequest
s = StringIO('')
env = TEST_ENVIRON.copy()
request = HTTPRequest(s, env, None)
self.assertEqual(request.method, 'GET')
env = TEST_ENVIRON.copy()
env['REQUEST_METHOD'] = 'post'
request = HTTPRequest(s, env, None)
self.assertEqual(request.method, 'POST')
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(AuthCredentialsTestsa, 'test'))
......
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