Class: QgsServerResponse¶
- class qgis.server.QgsServerResponse¶
Bases:
sip.wrapper
constructor
QgsServerResponse(
QgsServerResponse
)Methods
Reset all headers and content for this response
Gets the data written so far
Finish the response, ending the transaction.
Flushes the current output buffer to the network
Returns the header value
Returns the header value
Returns
True
if the headers have already been sentReturns the underlying QIODevice
Clear header Undo a previous 'setHeader' call
Send error This method delegates error handling at the server level.
Set Header entry Add Header entry to the response Note that it is usually an error to set Header after data have been sent through the wire
Set the http status code
Returns the http status code
Truncate data
Write string This is a convenient method that will write directly to the underlying I/O device
- clear(self)¶
Reset all headers and content for this response
- data(self) QByteArray ¶
Gets the data written so far
This is implementation dependent: some implementations may not give access to the underlying and return an empty array.
Note that each call to ‘flush’ may empty the buffer and in case of streaming process you may get partial content
- Return type:
QByteArray
- finish(self)¶
Finish the response, ending the transaction. The default implementation does nothing.
- flush(self)¶
Flushes the current output buffer to the network
‘
flush()
’ may be called multiple times. For HTTP transactions headers will be written on the first call to ‘flush()
’. The default implementation does nothing.
- header(self, key: str) str ¶
Returns the header value
- Parameters:
key (str) –
- Return type:
str
- headers(self) Dict[str, str] ¶
Returns the header value
- Return type:
Dict[str, str]
- headersSent(self) bool ¶
Returns
True
if the headers have already been sent- Return type:
bool
- io(self) QIODevice ¶
Returns the underlying QIODevice
- Return type:
QIODevice
- removeHeader(self, key: str)¶
Clear header Undo a previous ‘setHeader’ call
- Parameters:
key (str) –
- sendError(self, code: int, message: str)¶
Send error This method delegates error handling at the server level. This is different from calling
setReturnCode()
which let you return a specific response body. CallingsendError()
will end the transaction and any attempt to write data or set headers will be an error.- Parameters:
code (int) – HHTP return code value
message (str) – An informative error message
- setHeader(self, key: str, value: str)¶
Set Header entry Add Header entry to the response Note that it is usually an error to set Header after data have been sent through the wire
- Parameters:
key (str) –
value (str) –
- setStatusCode(self, code: int)¶
Set the http status code
- Parameters:
code (int) – HTTP status code value
- statusCode(self) int ¶
Returns the http status code
- Return type:
int
- truncate(self)¶
Truncate data
Clear internal buffer
- write(self, data: str)¶
Write string This is a convenient method that will write directly to the underlying I/O device
write(self, byteArray: Union[QByteArray, bytes, bytearray]) -> int Write chunk of data This is a convenient method that will write directly to the underlying I/O device
- Returns:
the number of bytes that were actually written
write(self, ex:
QgsServerException
) Write server exception- Parameters:
data (str) –