PySide6.QtHttpServer.QHttpServerResponse¶
- class QHttpServerResponse¶
Encapsulates an HTTP response. More…
Synopsis¶
Methods¶
def
__init__()
def
data()
def
headers()
def
mimeType()
def
setHeaders()
def
statusCode()
def
swap()
Static functions¶
def
fromFile()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
API for creating, reading and modifying a response from an HTTP server, and for writing its contents to a
QHttpServerResponder
. It has numerous constructors, andstatic
functionfromFile
for constructing it from the contents of a file. There are functions for setting, getting, and removing headers, and for getting the data, status code and mime type.- __init__(statusCode)¶
- Parameters:
statusCode –
StatusCode
- __init__(data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
data –
QByteArray
status –
StatusCode
- __init__(data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
data –
QJsonArray
status –
StatusCode
- __init__(data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
data –
QJsonObject
status –
StatusCode
- __init__(data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
data – str
status –
StatusCode
- __init__(data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
data – str
status –
StatusCode
- __init__(mimeType, data[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
mimeType –
QByteArray
data –
QByteArray
status –
StatusCode
- data()¶
- Return type:
Returns the response body.
- static fromFile(fileName)¶
- Parameters:
fileName – str
- Return type:
Returns a
QHttpServerResponse
from the content of the filefileName
.It is the caller’s responsibility to sanity-check the filename, and to have a well-defined policy for which files the server will request.
- headers()¶
- Return type:
Returns the currently set HTTP headers.
See also
- mimeType()¶
- Return type:
Returns the value of the HTTP “Content-Type” header.
Note
Default value is “text/html”
- setHeaders(newHeaders)¶
- Parameters:
newHeaders –
QHttpHeaders
This is an overloaded function.
- statusCode()¶
- Return type:
Returns the status code.
- swap(other)¶
- Parameters:
other –
QHttpServerResponse
Swaps this
QHttpServerResponse
withother
. This operation is very fast and never fails.