Class: QgsServerResponse¶
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: addHeader(), clear(), data(), fullHeader(), fullHeaders(), header(), headers(), headersSent(), io(), removeHeader(), sendError(), setHeader(), setStatusCode(), statusCode(), truncate()
List of all members, including inherited members
Class Hierarchy¶
Subclasses¶
Defines a buffered server response. |
Constructor
|
Abstract Methods
Add a header value for the given key, without replacing any existing value for the same key Add Header entry to the response |
|
Reset all headers and content for this response |
|
Gets the data written so far |
|
Returns a (possibly empty) list of all the header values for the given key |
|
Returns all the header values |
|
Returns a single header value for a given key |
|
Returns the header values as a map: only the last value is returned if multiple values are set for the same header |
|
Returns |
|
Returns the underlying QIODevice |
|
Clear all header values for the given key Undo a previous 'setHeader' call |
|
Send error This method delegates error handling at the server level. |
|
Set a single header value replacing any existing value(s) for the same key |
|
Set the http status code |
|
Returns the http status code |
|
Truncate data |
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 |
|
Finish the response, ending the transaction. |
|
Flushes the current output buffer to the network |
|
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 addHeader(self, key: str | None, value: str | None)[source]¶
Add a header
valuefor the givenkey, without replacing any existing value for the samekeyAdd Header entry to the responseNote
that it is usually an error to set Header after data have been sent through the wire
See also
setHeader()for a method that replaces any existing value(s) for the same header keyAdded in version 4.2.
- 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:
- virtual finish(self)[source]¶
Finish the response, ending the transaction. The default implementation does nothing.
- virtual 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 fullHeader(self, key: str | None) list[str]¶
Returns a (possibly empty) list of all the header values for the given
keySee also
header()to get only the last value for a given header keyAdded in version 4.2.
- Parameters:
key (Optional[str])
- Return type:
list[str]
- abstract fullHeaders(self) Any¶
Returns all the header values
See also
headers()to get only the last value for each header keyAdded in version 4.2.
- Return type:
- abstract header(self, key: str | None) str[source]¶
Returns a single header value for a given
keyNote
if multiple values are set for the same key, the last one is returned
Deprecated since version 4.2: Use
fullHeader()instead.- Parameters:
key (Optional[str])
- Return type:
str
- abstract headers(self) dict[str, str]¶
Returns the header values as a map: only the last value is returned if multiple values are set for the same header
See also
fullHeaders()to get all the values for all the headersDeprecated since version 4.2: Use
fullHeaders()instead.- Return type:
dict[str, str]
- abstract headersSent(self) bool[source]¶
Returns
Trueif 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 all header values for the given
keyUndo 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 a single header
valuereplacing any existing value(s) for the samekeyNote
that it is usually an error to set Header after data have been sent through the wire
See also
addHeader()for a method that allows setting multiple values for the same header keySee also
removeHeader()to clear header values for a given key
- 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
write(self, byteArray: Union[QByteArray, bytes, bytearray, memoryview]) -> 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 (Optional[str])