http Module

This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>

HTTP statuses helpers

exception gluon.http.HTTP(status, body='', cookies=None, **headers)[source]

Bases: exceptions.Exception

Raises an HTTP response

Parameters:
  • status – usually an integer. If it’s a well known status code, the ERROR message will be automatically added. A string can also be passed as 510 Foo Bar and in that case the status code and the error message will be parsed accordingly
  • body – what to return as body. If left as is, will return the error code and the status message in the body itself
  • cookies – pass cookies along (usually not needed)
  • headers – pass headers as usual dict mapping
cookies2headers(cookies)[source]
message

compose a message describing this exception

“status defined_status [web2py_error]”

message elements that are not defined are omitted

to(responder, env=None)[source]
gluon.http.redirect(location='', how=303, client_side=False, headers=None)[source]

Raises a redirect (303)

Parameters:
  • location – the url where to redirect
  • how – what HTTP status code to use when redirecting
  • client_side – if set to True, it triggers a reload of the entire page when the fragment has been loaded as a component