diff --git a/VERSION b/VERSION index f75be63a..49071fb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.9.5-trunk+timestamp.2014.08.07.23.42.12 +Version 2.9.5-trunk+timestamp.2014.08.07.23.47.27 diff --git a/gluon/http.py b/gluon/http.py index ce557572..91013b2d 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -150,7 +150,7 @@ class HTTP(Exception): return self.message -def redirect(location='', how=303, client_side=False): +def redirect(location='', how=303, client_side=False, headers=None): """Raises a redirect (303) Args: @@ -159,16 +159,19 @@ def redirect(location='', how=303, client_side=False): client_side: if set to True, it triggers a reload of the entire page when the fragment has been loaded as a component """ + headers = headers or {} if location: from gluon import current loc = location.replace('\r', '%0D').replace('\n', '%0A') + headers['web2py-redirect-location'] = loc if client_side and current.request.ajax: - raise HTTP(200, **{'web2py-redirect-location': loc}) + raise HTTP(200, **headers) else: raise HTTP(how, 'You are being redirected here' % loc, - Location=loc) + **headers) else: from gluon import current if client_side and current.request.ajax: - raise HTTP(200, **{'web2py-component-command': 'window.location.reload(true)'}) + headers['web2py-component-command'] = 'window.location.reload(true)' + raise HTTP(200, **headers)