Class: QgsRequestHandler

An interface hiding the details of reading input and writing output from/to a wms request mechanism.

class qgis.server.QgsRequestHandler[source]

Bases: object

__init__(request: QgsServerRequest, response: QgsServerResponse)

Constructor

Note that QgsServerRequest and QgsServerResponse MUST live in the same scope

Parameters:
__init__(a0: QgsRequestHandler)
Parameters:

a0 (QgsRequestHandler)

appendBody(self, body: QByteArray | bytes | bytearray)[source]

Sets the info format string such as “text/xml”

Parameters:

body (Union[QByteArray, bytes, bytearray])

body(self) QByteArray[source]

Returns the response body data

Return type:

QByteArray

clear(self)[source]

Clears the response body and headers

clearBody(self)[source]

Clear response buffer

data(self) QByteArray[source]

Returns the request POST data (can be null)

Return type:

QByteArray

exceptionRaised(self) bool[source]

Pointer to last raised exception

Return type:

bool

format(self) str[source]

Returns the requested format string

Return type:

str

headersSent(self) bool[source]

Returns True if the HTTP headers were already sent to the client

Return type:

bool

parameter(self, key: str | None) str[source]

Returns a request parameter

Parameters:

key (Optional[str])

Return type:

str

parameterMap(self) Dict[str, str]

Returns the parsed parameters as a key-value pair.

See also

setParameter()

Return type:

Dict[str, str]

path(self) str[source]

Returns the path component of the request URL

Added in version 3.16.

Return type:

str

removeParameter(self, key: str | None)[source]

Remove a request parameter

Parameters:

key (Optional[str])

removeRequestHeader(self, name: str | None)[source]

Remove an HTTP request header

Parameters:

name (Optional[str])

removeResponseHeader(self, name: str | None)[source]

Remove an HTTP response header

Parameters:

name (Optional[str])

requestHeader(self, name: str | None) str[source]

Retrieve request header value

Parameters:

name (Optional[str])

Return type:

str

requestHeaders(self) Dict[str, str]

Returns the the Request headers

Return type:

Dict[str, str]

responseHeader(self, name: str | None) str[source]

Retrieve response header value

Parameters:

name (Optional[str])

Return type:

str

responseHeaders(self) Dict[str, str]

Returns the response headers

Return type:

Dict[str, str]

sendResponse(self)[source]

Send out HTTP headers and flush output buffer

This method is intended only for streaming partial content.

setParameter(self, key: str | None, value: str | None)[source]

Sets a request parameter

Parameters:
  • key (Optional[str])

  • value (Optional[str])

setRequestHeader(self, name: str | None, value: str | None)[source]

Sets an HTTP request header

Parameters:
  • name (Optional[str])

  • value (Optional[str])

setResponseHeader(self, name: str | None, value: str | None)[source]

Sets an HTTP response header

Parameters:
  • name (Optional[str])

  • value (Optional[str])

setServiceException(self, ex: QgsServerException)[source]

Allow plugins to return a QgsMapServiceException

Parameters:

ex (QgsServerException)

setStatusCode(self, code: int)[source]

Sets response http status code

Parameters:

code (int)

statusCode(self) int[source]

Returns the response http status code

Return type:

int

url(self) str[source]

Returns the request url

Return type:

str