Changeset 2555
- Timestamp:
- 10/17/09 13:17:05
- Files:
-
- trunk/cherrypy/_cpreqbody.py (modified) (2 diffs)
- trunk/cherrypy/lib/profiler.py (modified) (1 diff)
- trunk/cherrypy/test/test_http.py (modified) (8 diffs)
- trunk/cherrypy/test/test_refleaks.py (modified) (2 diffs)
- trunk/cherrypy/test/test_states.py (modified) (1 diff)
- trunk/cherrypy/test/webtest.py (modified) (6 diffs)
- trunk/cherrypy/wsgiserver/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpreqbody.py
r2549 r2555 559 559 try: 560 560 data = self.fp.read(chunksize) 561 except IOError: 562 raise cherrypy.HTTPError(413) 561 except Exception, e: 562 if e.__class__.__name__ == 'MaxSizeExceeded': 563 # Post data is too big 564 raise cherrypy.HTTPError( 565 413, "Maximum request length: %r" % e.args[1]) 566 else: 567 raise 563 568 if not data: 564 569 self.finish() … … 645 650 v = ", ".join((existing, v)) 646 651 self.trailers[k] = v 647 except IOError: 648 raise cherrypy.HTTPError(413) 652 except Exception, e: 653 if e.__class__.__name__ == 'MaxSizeExceeded': 654 # Post data is too big 655 raise cherrypy.HTTPError( 656 413, "Maximum request length: %r" % e.args[1]) 657 else: 658 raise 649 659 650 660 trunk/cherrypy/lib/profiler.py
r2437 r2555 54 54 import os, os.path 55 55 import sys 56 import warnings 56 57 57 58 try: trunk/cherrypy/test/test_http.py
r2489 r2555 4 4 test.prefer_parent_path() 5 5 6 import httplib 6 from httplib import HTTPConnection, HTTPSConnection 7 7 import cherrypy 8 8 import mimetypes … … 79 79 # request.process_request_body to False for our handler. 80 80 if self.scheme == "https": 81 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT))81 c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 82 82 else: 83 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))83 c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 84 84 c.request("POST", "/no_body") 85 85 response = c.getresponse() … … 93 93 # with 411 Length Required. 94 94 if self.scheme == "https": 95 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT))95 c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 96 96 else: 97 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))97 c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 98 98 c.request("POST", "/") 99 99 response = c.getresponse() … … 113 113 # post file 114 114 if self.scheme == 'https': 115 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT))115 c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 116 116 else: 117 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))117 c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 118 118 c.putrequest('POST', '/post_multipart') 119 119 c.putheader('Content-Type', content_type) … … 134 134 # Test missing version in Request-Line 135 135 if self.scheme == 'https': 136 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT))136 c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 137 137 else: 138 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))138 c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 139 139 c._output('GET /') 140 140 c._send_output() … … 147 147 def test_malformed_header(self): 148 148 if self.scheme == 'https': 149 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT))149 c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 150 150 else: 151 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))151 c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 152 152 c.putrequest('GET', '/') 153 153 c.putheader('Content-Type', 'text/plain') … … 157 157 158 158 response = c.getresponse() 159 self.body = response.fp.read()160 159 self.status = str(response.status) 161 160 self.assertStatus(400) 161 self.body = response.fp.read() 162 162 self.assertBody("Illegal header line.") 163 163 … … 167 167 168 168 # Try connecting without SSL. 169 conn = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT))169 conn = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 170 170 conn.putrequest("GET", "/", skip_host=True) 171 171 conn.putheader("Host", self.HOST) trunk/cherrypy/test/test_refleaks.py
r2119 r2555 5 5 6 6 import gc 7 import httplib 7 from httplib import HTTPConnection, HTTPSConnection 8 8 import threading 9 9 … … 90 90 host = '%s:%s' % (self.interface(), self.PORT) 91 91 if self.scheme == 'https': 92 c = httplib.HTTPSConnection(host)92 c = HTTPSConnection(host) 93 93 else: 94 c = httplib.HTTPConnection(host)94 c = HTTPConnection(host) 95 95 try: 96 96 c.putrequest('GET', '/') trunk/cherrypy/test/test_states.py
r2437 r2555 1 import httplib2 1 from httplib import BadStatusLine 3 2 trunk/cherrypy/test/webtest.py
r2437 r2555 17 17 """ 18 18 19 import httplib 19 from httplib import HTTPConnection, HTTPSConnection 20 20 import os 21 21 import pprint … … 160 160 HOST = "127.0.0.1" 161 161 PORT = 8000 162 HTTP_CONN = httplib.HTTPConnection162 HTTP_CONN = HTTPConnection 163 163 PROTOCOL = "HTTP/1.1" 164 164 … … 174 174 """Return a connection to our HTTP server.""" 175 175 if self.scheme == "https": 176 cls = httplib.HTTPSConnection176 cls = HTTPSConnection 177 177 else: 178 cls = httplib.HTTPConnection178 cls = HTTPConnection 179 179 conn = cls(self.interface(), self.PORT) 180 180 # Automatically re-connect? … … 187 187 188 188 If the 'on' argument is True (the default), then self.HTTP_CONN 189 will be set to an instance of httplib.HTTPConnection (or HTTPS189 will be set to an instance of HTTPConnection (or HTTPS 190 190 if self.scheme is "https"). This will then persist across requests. 191 191 … … 202 202 else: 203 203 if self.scheme == "https": 204 self.HTTP_CONN = httplib.HTTPSConnection204 self.HTTP_CONN = HTTPSConnection 205 205 else: 206 self.HTTP_CONN = httplib.HTTPConnection206 self.HTTP_CONN = HTTPConnection 207 207 208 208 def _get_persistent(self): … … 512 512 513 513 def openURL(url, headers=None, method="GET", body=None, 514 host="127.0.0.1", port=8000, http_conn= httplib.HTTPConnection,514 host="127.0.0.1", port=8000, http_conn=HTTPConnection, 515 515 protocol="HTTP/1.1"): 516 516 """Open the given HTTP resource and return status, headers, and body.""" trunk/cherrypy/wsgiserver/__init__.py
r2549 r2555 304 304 305 305 306 class MaxSizeExceeded(Exception): 307 pass 308 309 306 310 class ChunkedRFile(object): 307 311 """Wraps a file-like object, returning an empty string when exhausted. … … 328 332 329 333 if self.maxlen and self.bytes_read > self.maxlen: 330 raise IOError("Request Entity Too Large")334 raise MaxSizeExceeded("Request Entity Too Large", self.maxlen) 331 335 332 336 line = line.strip().split(";", 1)

