Class: QgsServerResponse¶
Class Hierarchy¶
Subclasses¶
Class defining buffered response |
Methods
Reset all headers and content for this response |
|
Gets the data written so far |
|
Returns the socket feedback if any |
|
Finish the response, ending the transaction. |
|
Flushes the current output buffer to the network |
|
Returns the header value |
|
Returns the header value |
|
Returns |
|
Returns 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 |
- class qgis.server.QgsServerResponse[source]¶
- class qgis.server.QgsServerResponse(a0: QgsServerResponse)
Bases:
object
- data(self) QByteArray [source]¶
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
- feedback(self) QgsFeedback | None [source]¶
Returns the socket feedback if any
Added in version 3.36.
- Return type:
Optional[QgsFeedback]
- finish(self)[source]¶
Finish the response, ending the transaction. The default implementation does nothing.
- flush(self)[source]¶
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 | None) str [source]¶
Returns the header value
- Parameters:
key (Optional[str])
- Return type:
str
- headers(self) Dict[str, str] ¶
Returns the header value
- Return type:
Dict[str, str]
- headersSent(self) bool [source]¶
Returns
True
if the headers have already been sent- Return type:
bool
- io(self) QIODevice | None [source]¶
Returns the underlying QIODevice
- Return type:
Optional[QIODevice]
- removeHeader(self, key: str | None)[source]¶
Clear header Undo a previous ‘setHeader’ call
- Parameters:
key (Optional[str])
- sendError(self, code: int, message: str | None)[source]¶
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 (Optional[str]) – An informative error message
- setHeader(self, key: str | None, value: str | None)[source]¶
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 (Optional[str])
value (Optional[str])
- setStatusCode(self, code: int)[source]¶
Set the http status code
- Parameters:
code (int) – HTTP status code value
- write(self, data: str | None)[source]¶
Write string This is a convenient method that will write directly to the underlying I/O device
- Parameters:
data (Optional[str])
- write(self, byteArray: QByteArray | bytes | bytearray) int [source]
Write chunk of data This is a convenient method that will write directly to the underlying I/O device
- Return type:
int
- Returns:
the number of bytes that were actually written
- Parameters:
byteArray (Union[QByteArray, bytes, bytearray])
- write(self, ex: QgsServerException)[source]
Write server exception
- Parameters:
ex (
QgsServerException
)