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

Changeset 525

Show
Ignore:
Timestamp:
08/09/05 17:54:54
Author:
fumanchu
Message:

Changed virtualhostfilter from beforeRequestBody to onStartResource, now that request.path is available so early.

Files:

Legend:

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

    r523 r525  
    240240            # HEAD requests MUST NOT return a message-body in the response. 
    241241            cherrypy.response.body = [] 
     242     
     243    def parseFirstLine(self): 
     244        # This has to be done very early in the request process, 
     245        # because request.path is used for config lookups right away. 
     246        req = cherrypy.request 
     247         
     248        # Parse first line 
     249        req.method, path, req.protocol = req.requestLine.split() 
     250        req.processRequestBody = req.method in ("POST", "PUT") 
     251         
     252        # separate the queryString, or set it to "" if not found 
     253        if "?" in path: 
     254            path, req.queryString = path.split("?", 1) 
     255        else: 
     256            path, req.queryString = path, "" 
     257         
     258        # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
     259        if path == "*": 
     260            path = "global" 
     261        elif not path.startswith("/"): 
     262            # path is an absolute path (including "http://host.domain.tld"); 
     263            # convert it to a relative path, so configMap lookups work. This 
     264            # default method assumes all hosts are valid for this server. 
     265            scheme, location, p, pm, q, f = urlparse(path) 
     266            path = path[len(scheme + "://" + location):] 
     267         
     268        # Save original value (in case it gets modified by filters) 
     269        req.path = req.originalPath = path 
     270         
     271        # Change objectPath in filters to change 
     272        # the object that will get rendered 
     273        req.objectPath = None 
    242274     
    243275    def run(self): 
     
    275307            handleError(sys.exc_info()) 
    276308     
    277     def parseFirstLine(self): 
    278         # This has to be done very early in the request process, 
    279         # because request.path is used for config lookups right away. 
    280         req = cherrypy.request 
    281          
    282         # Parse first line 
    283         req.method, path, req.protocol = req.requestLine.split() 
    284         req.processRequestBody = req.method in ("POST", "PUT") 
    285          
    286         # separate the queryString, or set it to "" if not found 
    287         if "?" in path: 
    288             path, req.queryString = path.split("?", 1) 
    289         else: 
    290             path, req.queryString = path, "" 
    291          
    292         # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 
    293         if path == "*": 
    294             path = "global" 
    295         elif not path.startswith("/"): 
    296             # path is an absolute path (including "http://host.domain.tld"); 
    297             # convert it to a relative path, so configMap lookups work. This 
    298             # default method assumes all hosts are valid for this server. 
    299             scheme, location, p, pm, q, f = urlparse(path) 
    300             path = path[len(scheme + "://" + location):] 
    301          
    302         # Save original value (in case it gets modified by filters) 
    303         req.path = req.originalPath = path 
    304      
    305309    def processRequestHeaders(self): 
    306310        req = cherrypy.request 
     
    346350        msg = "%s - %s" % (req.remoteAddr, req.requestLine) 
    347351        cherrypy.log(msg, "HTTP") 
    348          
    349         # Change objectPath in filters to change 
    350         # the object that will get rendered 
    351         req.objectPath = None 
    352352         
    353353        # Save original values (in case they get modified by filters) 
  • trunk/cherrypy/lib/filter/virtualhostfilter.py

    r382 r525  
    3636    """ 
    3737     
    38     def beforeRequestBody(self): 
     38    def onStartResource(self): 
    3939        import cherrypy 
    4040        from cherrypy import _cphttptools 
     
    4343            return 
    4444         
    45         domain = cherrypy.request.base.split('//')[1] 
    4645        # Re-use "mapPathToObject" function to find the actual objectPath 
    4746        prefix = cherrypy.config.get('virtualHostFilter.prefix', '/') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets