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

Ticket #755 (defect)

Opened 9 months ago

Last modified 4 months ago

trailing_slash not working for static files in 3.1 beta

Status: closed (worksforme)

Reported by: ricardo Assigned to: rdelon
Priority: normal Milestone: 3.1
Component: CherryPy code Keywords: trailing_slash staticdir
Cc:

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.

Change History

01/12/08 18:02:30: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to worksforme.

http://www.cherrypy.org/browser/trunk/cherrypy/test/test_static.py#L110 shows that it works as far as I can see for 3.1. If you can add a similar test with your config that fails, feel free to reopen this ticket.

01/20/08 11:41:24: Modified by ricardo

  • status changed from closed to reopened.
  • resolution deleted.

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.

03/07/08 16:21:34: Modified by fumanchu

Test added in [1910], but it passes for me. If anyone can see where I screwed up, let me know, but I can't reproduce the problem.

04/26/08 18:42:31: Modified by fumanchu

  • status changed from reopened to closed.
  • resolution set to worksforme.

Hosted by WebFaction

Log in as guest/cpguest to create tickets