Note
This class is accessible using both hou.WebServerResponse and
hou.webServer.Response, but hou.webServer.Response is preferable.
Methods ¶
__init__(data, status=200, content_type="text/html", is_file_name=False, delete_file=False)
data
The contents of the response. This must be a str for Python 2,
and a bytes object for Python 3 (see HOM binary data
support for more information). The object will
automatically set the Content-Length header unless you set the
Transfer-Encoding header to chunked.
status
The HTTP status number to respond with.
content_type
The MIME type of the response content.
is_file_name
If True, treat the data string as a file name, and send the
contents of the file to the client.
delete_file
If this is True, and is_file_name is True, the server deletes the
file after sending it to the client. This is useful for temp files.
setHeader(header_name, header_value)
→ str
Add/change an HTTP header in the response.
headers()
→ dict
of str
to str
Returns a dictionary of all headers in the response.
Calling this method generates a new copy of the dictionary each time, so you are advised to avoid calling it more times than necessary.
statusLabel()
→ str
Return the status label of the response. An exampe label would be 200 OK.
Calling this method generates a new copy of the string each time, so you are advised to avoid calling it more times than necessary.
body()
→ str
Returns the body of the response.
Calling this method generates a new copy of the string each time, so you are advised to avoid calling it more times than necessary.