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

Changeset 812

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

httptools.Version object now takes ints and floats as constructor args (and therefore can compare against ints and floats, now). Also moved cherrypy.request/response.version logic from processHeaders to processRequestLine.

Files:

Legend:

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

    r811 r812  
    6363            # right away. 
    6464            self.processRequestLine(requestLine) 
    65  
     65             
    6666            # if we receive OPTIONS * HTTP/1.1 
    6767            # then we should simply answer right away 
     
    7171                if self.path == 'global': 
    7272                    # OPTIONS is defined in HTTP 1.1 
    73                     if self.protocol == 'HTTP/1.1': 
    74                         cherrypy.response.body = [] 
    75                         cherrypy.response.status = '200 OK' 
    76                         cherrypy.response.headerMap['Allow'] = 'HEAD, GET, POST, PUT, OPTIONS' 
    77                         cherrypy.response.headerMap['Content-Length'] = 0 
    78                         cherrypy.response.headerMap['Content-Type'] = 'text/plain' 
    79                         cherrypy.response.finalize() 
     73                    response = cherrypy.response 
     74                    if response.version >= '1.1': 
     75                        response.body = [] 
     76                        response.status = '200 OK' 
     77                        response.headerMap['Allow'] = 'HEAD, GET, POST, PUT, OPTIONS' 
     78                        response.headerMap['Content-Length'] = 0 
     79                        response.headerMap['Content-Type'] = 'text/plain' 
     80                        response.finalize() 
    8081                        _cputil.getSpecialAttribute("_cpLogAccess")() 
    8182                        return 
    82                      
     83             
    8384            try: 
    8485                applyFilters('onStartResource') 
     
    135136        # the object that will get rendered 
    136137        self.objectPath = path 
    137      
    138     def processHeaders(self): 
     138         
    139139        # Compare request and server HTTP versions, in case our server does 
    140140        # not support the requested version. We can't tell the server what 
     
    159159        # not to include a given HTTP/1.1 feature in the response content. 
    160160        cherrypy.response.version = min(self.version, server_v) 
     161     
     162    def processHeaders(self): 
    161163         
    162164        self.paramMap = httptools.parseQueryString(self.queryString) 
  • trunk/cherrypy/lib/httptools.py

    r801 r812  
    6161     
    6262    def __init__(self, atoms): 
    63         """A Version object. A str argument will be split on word boundaries.""" 
     63        """A Version object. 
     64         
     65        atoms: if a str, it will be split on word boundaries; 
     66               if a float or int, it will be split at the decimal point. 
     67        """ 
     68        if isinstance(atoms, (int, float)): 
     69            atoms = str(atoms) 
    6470        if isinstance(atoms, basestring): 
    6571            self.atoms = re.split(r'\W', atoms) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets