Issue #123 resolved

Redirect bug

Anonymous created an issue

I found some slightly annoying bug in httplib.redirect function, that appears when using certain url parameters. The easy way to reproduce it is to try to make a redirect from url like:


Instead of using cherrypy's own url tokenizing logic I simply suggest to use standard urlparse module. Following code works perfectly for me, and IMHO is much more cleaner.

from urlparse import urljoin

def redirect(newUrl): """ Sends a redirect to the browser """ newUrl = urljoin(cpg.request.browserUrl, newUrl) cpg.response.headerMap['Status'] = 302 cpg.response.headerMap['Location'] = newUrl return ''

Also instead of returning list it now returns string, as previously it could have generated some problems.

Reported by Michal Zylinski

Comments (3)

  1. Log in to comment