Beispiel #1
0
int32_t TestInterface::processHeader() {
  // Handler method can touch header at any time. Use this to test race
  // condition on per-request THeader.
  auto header = getConnectionContext()->getHeader();
  for (int i = 0; i < 1000000; i++) {
    header->setHeader("foo", "bar");
    header->clearHeaders();
  }
  return 1;
}
void QgsHttpRequestHandler::setServiceException( QgsMapServiceException ex )
{
  mException = &ex;
  //create Exception DOM document
  QDomDocument exceptionDoc;
  QDomElement serviceExceptionReportElem = exceptionDoc.createElement( "ServiceExceptionReport" );
  serviceExceptionReportElem.setAttribute( "version", "1.3.0" );
  serviceExceptionReportElem.setAttribute( "xmlns", "http://www.opengis.net/ogc" );
  exceptionDoc.appendChild( serviceExceptionReportElem );
  QDomElement serviceExceptionElem = exceptionDoc.createElement( "ServiceException" );
  serviceExceptionElem.setAttribute( "code", ex.code() );
  QDomText messageText = exceptionDoc.createTextNode( ex.message() );
  serviceExceptionElem.appendChild( messageText );
  serviceExceptionReportElem.appendChild( serviceExceptionElem );

  QByteArray ba = exceptionDoc.toByteArray();
  // Clear response headers and body and set new exception
  // TODO: check for headersSent()
  clearHeaders();
  clearBody();
  setHttpResponse( &ba, "text/xml" );
}