Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2555

Show
Ignore:
Timestamp:
10/17/09 13:17:05
Author:
fumanchu
Message:

A couple syncs with python3.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cpreqbody.py

    r2549 r2555  
    559559            try: 
    560560                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 
    563568            if not data: 
    564569                self.finish() 
     
    645650                            v = ", ".join((existing, v)) 
    646651                    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 
    649659 
    650660 
  • trunk/cherrypy/lib/profiler.py

    r2437 r2555  
    5454import os, os.path 
    5555import sys 
     56import warnings 
    5657 
    5758try: 
  • trunk/cherrypy/test/test_http.py

    r2489 r2555  
    44test.prefer_parent_path() 
    55 
    6 import httplib 
     6from httplib import HTTPConnection, HTTPSConnection 
    77import cherrypy 
    88import mimetypes 
     
    7979        # request.process_request_body to False for our handler. 
    8080        if self.scheme == "https": 
    81             c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
     81            c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
    8282        else: 
    83             c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     83            c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    8484        c.request("POST", "/no_body") 
    8585        response = c.getresponse() 
     
    9393        # with 411 Length Required. 
    9494        if self.scheme == "https": 
    95             c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
     95            c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
    9696        else: 
    97             c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     97            c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    9898        c.request("POST", "/") 
    9999        response = c.getresponse() 
     
    113113        # post file 
    114114        if self.scheme == 'https': 
    115             c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
     115            c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
    116116        else: 
    117             c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     117            c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    118118        c.putrequest('POST', '/post_multipart') 
    119119        c.putheader('Content-Type', content_type) 
     
    134134        # Test missing version in Request-Line 
    135135        if self.scheme == 'https': 
    136             c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
     136            c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
    137137        else: 
    138             c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     138            c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    139139        c._output('GET /') 
    140140        c._send_output() 
     
    147147    def test_malformed_header(self): 
    148148        if self.scheme == 'https': 
    149             c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
     149            c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 
    150150        else: 
    151             c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     151            c = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    152152        c.putrequest('GET', '/') 
    153153        c.putheader('Content-Type', 'text/plain') 
     
    157157         
    158158        response = c.getresponse() 
    159         self.body = response.fp.read() 
    160159        self.status = str(response.status) 
    161160        self.assertStatus(400) 
     161        self.body = response.fp.read() 
    162162        self.assertBody("Illegal header line.") 
    163163     
     
    167167         
    168168        # Try connecting without SSL. 
    169         conn = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
     169        conn = HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 
    170170        conn.putrequest("GET", "/", skip_host=True) 
    171171        conn.putheader("Host", self.HOST) 
  • trunk/cherrypy/test/test_refleaks.py

    r2119 r2555  
    55 
    66import gc 
    7 import httplib 
     7from httplib import HTTPConnection, HTTPSConnection 
    88import threading 
    99 
     
    9090            host = '%s:%s' % (self.interface(), self.PORT) 
    9191            if self.scheme == 'https': 
    92                 c = httplib.HTTPSConnection(host) 
     92                c = HTTPSConnection(host) 
    9393            else: 
    94                 c = httplib.HTTPConnection(host) 
     94                c = HTTPConnection(host) 
    9595            try: 
    9696                c.putrequest('GET', '/') 
  • trunk/cherrypy/test/test_states.py

    r2437 r2555  
    1 import httplib 
    21from httplib import BadStatusLine 
    32 
  • trunk/cherrypy/test/webtest.py

    r2437 r2555  
    1717""" 
    1818 
    19 import httplib 
     19from httplib import HTTPConnection, HTTPSConnection 
    2020import os 
    2121import pprint 
     
    160160    HOST = "127.0.0.1" 
    161161    PORT = 8000 
    162     HTTP_CONN = httplib.HTTPConnection 
     162    HTTP_CONN = HTTPConnection 
    163163    PROTOCOL = "HTTP/1.1" 
    164164     
     
    174174        """Return a connection to our HTTP server.""" 
    175175        if self.scheme == "https": 
    176             cls = httplib.HTTPSConnection 
     176            cls = HTTPSConnection 
    177177        else: 
    178             cls = httplib.HTTPConnection 
     178            cls = HTTPConnection 
    179179        conn = cls(self.interface(), self.PORT) 
    180180        # Automatically re-connect? 
     
    187187         
    188188        If the 'on' argument is True (the default), then self.HTTP_CONN 
    189         will be set to an instance of httplib.HTTPConnection (or HTTPS 
     189        will be set to an instance of HTTPConnection (or HTTPS 
    190190        if self.scheme is "https"). This will then persist across requests. 
    191191         
     
    202202        else: 
    203203            if self.scheme == "https": 
    204                 self.HTTP_CONN = httplib.HTTPSConnection 
     204                self.HTTP_CONN = HTTPSConnection 
    205205            else: 
    206                 self.HTTP_CONN = httplib.HTTPConnection 
     206                self.HTTP_CONN = HTTPConnection 
    207207     
    208208    def _get_persistent(self): 
     
    512512 
    513513def 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, 
    515515            protocol="HTTP/1.1"): 
    516516    """Open the given HTTP resource and return status, headers, and body.""" 
  • trunk/cherrypy/wsgiserver/__init__.py

    r2549 r2555  
    304304 
    305305 
     306class MaxSizeExceeded(Exception): 
     307    pass 
     308 
     309 
    306310class ChunkedRFile(object): 
    307311    """Wraps a file-like object, returning an empty string when exhausted. 
     
    328332         
    329333        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
    331335         
    332336        line = line.strip().split(";", 1) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets