Issue #755 resolved

trailing_slash not working for static files in 3.1 beta

ricardo
created an issue

In response to ticket 689, a fix was added in 3.0 to cause CherryPy to add a trailing_slash for static as well as dynamic index handlers. That fix doesn't seem to have made it into the 3.1 beta. At least I'm not getting redirects for URLs to static directories that lack a trailing slash. Just in case it matters, I'll point out that the directories that are generating this bad behavior have a different staticdir.index property than is specified in my global config.

Comments (6)

  1. ricardo reporter

    The problem arises in 3.1 (beta 3) when static directories are combined with the new VirtualHost WSGI middleware.

    I added the following to test_static.py after line 55:

      test_app_conf = {
        '/test':{
          'tools.staticdir.index':'index.html',
          'tools.staticdir.on':True,
          'tools.staticdir.root':curdir,
          'tools.staticdir.dir':'static',
        },
      }
    
      rootApp = cherrypy.Application(root)
      testApp = cherrypy.Application(Static())
      testApp.merge(test_app_conf)
      vhostmap = {'virtual.net':testApp}
      vhost = cherrypy._cpwsgi.VirtualHost(rootApp, vhostmap)
      cherrypy.tree.graft(vhost)
    

    Then I modified lines 106 and 111 respectively to include a Host header:

      self.getPage("/test/", [('Host', 'virtual.net')])
      ...
      self.getPage("/test", [('Host', 'virtual.net')])
    

    With these changes, the test suite fails at (the current) line 113, as one would expect if a missing trailing slash isn't getting added automatically.

  2. Log in to comment