PySide6.QtHttpServer.QHttpServerResponder¶
- class QHttpServerResponder¶
- API for sending replies from an HTTP server. More… - Synopsis¶- Methods¶- def - sendResponse()
- def - swap()
- def - write()
- def - writeChunk()
 - 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¶- Provides functions for writing back to an HTTP client with overloads for serializing JSON objects. It also has support for writing HTTP headers and status code. - class StatusCode¶
- HTTP status codes - Constant - Description - QHttpServerResponder.StatusCode.Continue - QHttpServerResponder.StatusCode.SwitchingProtocols - QHttpServerResponder.StatusCode.Processing - QHttpServerResponder.StatusCode.Ok - QHttpServerResponder.StatusCode.Created - QHttpServerResponder.StatusCode.Accepted - QHttpServerResponder.StatusCode.NonAuthoritativeInformation - QHttpServerResponder.StatusCode.NoContent - QHttpServerResponder.StatusCode.ResetContent - QHttpServerResponder.StatusCode.PartialContent - QHttpServerResponder.StatusCode.MultiStatus - QHttpServerResponder.StatusCode.AlreadyReported - QHttpServerResponder.StatusCode.IMUsed - QHttpServerResponder.StatusCode.MultipleChoices - QHttpServerResponder.StatusCode.MovedPermanently - QHttpServerResponder.StatusCode.Found - QHttpServerResponder.StatusCode.SeeOther - QHttpServerResponder.StatusCode.NotModified - QHttpServerResponder.StatusCode.UseProxy - QHttpServerResponder.StatusCode.TemporaryRedirect - QHttpServerResponder.StatusCode.PermanentRedirect - QHttpServerResponder.StatusCode.BadRequest - QHttpServerResponder.StatusCode.Unauthorized - QHttpServerResponder.StatusCode.PaymentRequired - QHttpServerResponder.StatusCode.Forbidden - QHttpServerResponder.StatusCode.NotFound - QHttpServerResponder.StatusCode.MethodNotAllowed - QHttpServerResponder.StatusCode.NotAcceptable - QHttpServerResponder.StatusCode.ProxyAuthenticationRequired - QHttpServerResponder.StatusCode.RequestTimeout - QHttpServerResponder.StatusCode.Conflict - QHttpServerResponder.StatusCode.Gone - QHttpServerResponder.StatusCode.LengthRequired - QHttpServerResponder.StatusCode.PreconditionFailed - QHttpServerResponder.StatusCode.PayloadTooLarge - QHttpServerResponder.StatusCode.UriTooLong - QHttpServerResponder.StatusCode.UnsupportedMediaType - QHttpServerResponder.StatusCode.RequestRangeNotSatisfiable - QHttpServerResponder.StatusCode.ExpectationFailed - QHttpServerResponder.StatusCode.ImATeapot - QHttpServerResponder.StatusCode.MisdirectedRequest - QHttpServerResponder.StatusCode.UnprocessableEntity - QHttpServerResponder.StatusCode.Locked - QHttpServerResponder.StatusCode.FailedDependency - QHttpServerResponder.StatusCode.UpgradeRequired - QHttpServerResponder.StatusCode.PreconditionRequired - QHttpServerResponder.StatusCode.TooManyRequests - QHttpServerResponder.StatusCode.RequestHeaderFieldsTooLarge - QHttpServerResponder.StatusCode.UnavailableForLegalReasons - QHttpServerResponder.StatusCode.InternalServerError - QHttpServerResponder.StatusCode.NotImplemented - QHttpServerResponder.StatusCode.BadGateway - QHttpServerResponder.StatusCode.ServiceUnavailable - QHttpServerResponder.StatusCode.GatewayTimeout - QHttpServerResponder.StatusCode.HttpVersionNotSupported - QHttpServerResponder.StatusCode.VariantAlsoNegotiates - QHttpServerResponder.StatusCode.InsufficientStorage - QHttpServerResponder.StatusCode.LoopDetected - QHttpServerResponder.StatusCode.NotExtended - QHttpServerResponder.StatusCode.NetworkAuthenticationRequired - QHttpServerResponder.StatusCode.NetworkConnectTimeoutError 
 - sendResponse(response)¶
- Parameters:
- response – - QHttpServerResponse
 
 - Sends a HTTP - responseto the client.- swap(other)¶
- Parameters:
- other – - QHttpServerResponder
 
 - Swaps - QHttpServerResponder- otherwith this- QHttpServerResponder. This operation is very fast and never fails.- write([status=QHttpServerResponder.StatusCode.Ok])¶
- Parameters:
- status – - StatusCode
 
 - Answers a request with an HTTP status code - status.- Note: This function sets HTTP Content-Type header as “application/x-empty”. - write(headers[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- headers – - QHttpHeaders
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - statusand HTTP Headers- headers.- write(document[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- document – - QJsonDocument
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - status, and JSON document- document.- Note: This function sets HTTP Content-Type header as “application/json”. - write(data, mimeType[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- data – - QIODevice
- mimeType – - QByteArray
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - statusand a MIME type- mimeType. The I/O device- dataprovides the body of the response. If- datais sequential, the body of the message is sent in chunks: otherwise, the function assumes all the content is available and sends it all at once but the read is done in chunks.- Note - This function takes the ownership of - data.- write(data, headers[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- data – - QIODevice
- headers – - QHttpHeaders
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - statusand HTTP headers- headers. The I/O device- dataprovides the body of the response. If- datais sequential, the body of the message is sent in chunks: otherwise, the function assumes all the content is available and sends it all at once but the read is done in chunks.- Note - This function takes the ownership of - data.- write(data, mimeType[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- data – - QByteArray
- mimeType – - QByteArray
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - status, a MIME type- mimeTypeand a body- data.- write(data, headers[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- data – - QByteArray
- headers – - QHttpHeaders
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - status, HTTP Headers- headersand a body- data.- Note: This function sets HTTP Content-Length header. - write(document, headers[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- document – - QJsonDocument
- headers – - QHttpHeaders
- status – - StatusCode
 
 
 - Answers a request with an HTTP status code - status, JSON document- documentand HTTP headers- headers.- Note: This function sets HTTP Content-Type header as “application/json”. - writeBeginChunked(mimeType[, status=QHttpServerResponder.StatusCode.Ok])¶
- Parameters:
- mimeType – - QByteArray
- status – - StatusCode
 
 
 - Start sending chunks of data with the mime type - mimeTypeand and the given status code- status. This call must be followed up with an arbitrary number of repeated- writeChunkcalls and and a single call to- writeEndChunked.- See also - writeBeginChunked(headers[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- headers – - QHttpHeaders
- status – - StatusCode
 
 
 - Start sending chunks of data with - headersand and the status code- status. This call must be followed up with an arbitrary number of repeated- writeChunkcalls and and a single call to- writeEndChunked.- See also - writeBeginChunked(headers, trailerNames[, status=QHttpServerResponder.StatusCode.Ok])
- Parameters:
- headers – - QHttpHeaders
- trailerNames – .list of QHttpHeaders.WellKnownHeader 
- status – - StatusCode
 
 
 - Start sending chunks of data with - headersand and the given status code- status. This call must be followed up with an arbitrary number of repeated- writeChunkcalls and and a single call to- writeEndChunkedwith the same trailers given in- trailers.- See also - writeChunk(data)¶
- Parameters:
- data – - QByteArray
 
 - Write - databack to the client. To be called when data is available to write. This can be called multiple times, but before calling this- writeBeginChunkedmust called, and afterwards- writeEndChunkedmust be called.- See also - writeEndChunked(data)¶
- Parameters:
- data – - QByteArray
 
 - Write - databack to the client. Must be preceded by a call to- writeBeginChunked.- See also - writeEndChunked(data, trailers)
- Parameters:
- data – - QByteArray
- trailers – - QHttpHeaders
 
 
 - Write - databack to the client with the- trailersannounced in- writeBeginChunked.- See also