Class: QgsServerResponse¶
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clear()
, data()
, header()
, headers()
, headersSent()
, io()
, removeHeader()
, sendError()
, setHeader()
, setStatusCode()
, statusCode()
, truncate()
Class Hierarchy¶
Subclasses¶
Defines a buffered server response. |
Abstract Methods
Reset all headers and content for this response |
|
Gets the data written so far |
|
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 |
Methods
Finish the response, ending the transaction. |
|
Flushes the current output buffer to the network |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsServerResponse. See the FAQ for more details.
Returns the socket feedback if any |
|
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
- abstract 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
- virtual 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.
- abstract header(self, key: str | None) str [source]¶
Returns the header value
- Parameters:
key (Optional[str])
- Return type:
str
- abstract headers(self) Dict[str, str] ¶
Returns the header value
- Return type:
Dict[str, str]
- abstract headersSent(self) bool [source]¶
Returns
True
if the headers have already been sent- Return type:
bool
- abstract io(self) QIODevice | None [source]¶
Returns the underlying QIODevice
- Return type:
Optional[QIODevice]
- abstract removeHeader(self, key: str | None)[source]¶
Clear header Undo a previous ‘setHeader’ call
- Parameters:
key (Optional[str])
- abstract 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
- abstract 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])
- abstract setStatusCode(self, code: int)[source]¶
Set the http status code
- Parameters:
code (int) – HTTP status code value
- virtual 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])
- virtual 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])
- virtual write(self, ex: QgsServerException)[source]
Write server exception
- Parameters:
ex (
QgsServerException
)