Class: QgsRequestHandler

class qgis.server.QgsRequestHandler(request: QgsServerRequest, response: QgsServerResponse)

Bases: sip.wrapper

Constructor

Note that QgsServerRequest and QgsServerResponse MUST live in the same scope

QgsRequestHandler(QgsRequestHandler)

This class is an interface hiding the details of reading input and writing output from/to a wms request mechanism.

Parameters
appendBody(self, body: Union[QByteArray, bytes, bytearray])

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

Parameters

body (Union[QByteArray) –

body(self) → QByteArray

Returns the response body data

Return type

QByteArray

clear(self)

Clears the response body and headers

clearBody(self)

Clear response buffer

data(self) → QByteArray

Returns the request POST data (can be null)

Return type

QByteArray

exceptionRaised(self) → bool

Pointer to last raised exception

Return type

bool

format(self) → str

Returns the requested format string

Return type

str

headersSent(self) → bool

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

Return type

bool

parameter(self, key: str) → str

Returns a request parameter

Parameters

key (str) –

Return type

str

parameterMap(self) → Dict[str, str]

Returns the parsed parameters as a key-value pair, to modify a parameter setParameter( const QString &key, const QString &value) and removeParameter(const QString &key) must be used

Return type

Dict[str, str]

removeParameter(self, key: str)

Remove a request parameter

Parameters

key (str) –

removeRequestHeader(self, name: str)

Remove an HTTP request header

Parameters

name (str) –

removeResponseHeader(self, name: str)

Remove an HTTP response header

Parameters

name (str) –

requestHeader(self, name: str) → str

Retrieve request header value

Parameters

name (str) –

Return type

str

requestHeaders(self) → Dict[str, str]

Returns the the Request headers

Return type

Dict[str, str]

responseHeader(self, name: str) → str

Retrieve response header value

Parameters

name (str) –

Return type

str

responseHeaders(self) → Dict[str, str]

Returns the response headers

Return type

Dict[str, str]

sendResponse(self)

Send out HTTP headers and flush output buffer

This method is intended only for streaming partial content.

setParameter(self, key: str, value: str)

Sets a request parameter

Parameters
  • key (str) –

  • value (str) –

setRequestHeader(self, name: str, value: str)

Sets an HTTP request header

Parameters
  • name (str) –

  • value (str) –

setResponseHeader(self, name: str, value: str)

Sets an HTTP response header

Parameters
  • name (str) –

  • value (str) –

setServiceException(self, ex: QgsServerException)

Allow plugins to return a QgsMapServiceException

Parameters

ex (QgsServerException) –

setStatusCode(self, code: int)

Sets response http status code

Parameters

code (int) –

statusCode(self) → int

Returns the response http status code

Return type

int

url(self) → str

Returns the request url

Return type

str