bool QgsHttpRequestHandler::startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) { if ( !ba ) { return false; } if ( ba->size() < 1 ) { return false; } QString format; if ( infoFormat == "GeoJSON" ) format = "text/plain"; else format = "text/xml"; setInfoFormat( format ); sendHeaders(); appendBody( *ba ); // Streaming sendResponse(); return true; }
void QgsRequestHandler::endGetFeatureResponse( QByteArray* ba ) { if ( !ba ) { return; } appendBody( *ba ); // do NOT call sendResponse() // finish will be called at the end of the transaction }
void QgsHttpRequestHandler::endGetFeatureResponse( QByteArray* ba ) { if ( !ba ) { return; } appendBody( *ba ); // Streaming sendResponse(); }
void QgsRequestHandler::setHttpResponse( const QByteArray& ba, const QString &format ) { QgsMessageLog::logMessage( QStringLiteral( "Checking byte array is ok to set..." ) ); if ( ba.size() < 1 ) { return; } QgsMessageLog::logMessage( QStringLiteral( "Byte array looks good, setting response..." ) ); appendBody( ba ); setInfoFormat( format ); }
void QgsRequestHandler::setGetFeatureResponse( QByteArray* ba ) { if ( !ba ) { return; } if ( ba->size() < 1 ) { return; } appendBody( *ba ); // Streaming sendResponse(); }
void QgsHttpRequestHandler::setHttpResponse( QByteArray *ba, const QString &format ) { QgsMessageLog::logMessage( "Checking byte array is ok to set..." ); if ( !ba ) { return; } if ( ba->size() < 1 ) { return; } QgsMessageLog::logMessage( "Byte array looks good, setting response..." ); appendBody( *ba ); mInfoFormat = format; }
HttpMessage *httpc_parser_parse(HttpMessage *saved, const char *data, int len, int *used) { ParserData *pd; HttpMessage *msg = saved; const char *p = data; *used = 0; if (!msg) { msg = httpc_Message_create(); msg->pri_data = malloc(sizeof(ParserData)); pd = (ParserData *)msg->pri_data; pd->linedata = 0; pd->line_bufsize = 0; pd->line_datasize = 0; pd->state = HTTP_STARTLINE; } else { pd = (ParserData *)msg->pri_data; } while (pd->state != HTTP_COMPLETE && len > 0) { if (pd->state == HTTP_BODY) { const char *v = 0; int rc; int bodylen, expect; httpc_Message_getValue(msg, "Content-Length", &v); bodylen = atoi(v); expect = bodylen - msg->bodylen; rc = appendBody(p, len > expect ? expect : len, msg); p += rc; len -= rc; *used += rc; } else { int rc = appendByte(*p, msg); p += rc; len -= rc; *used += rc; } } return msg; }
bool QgsRequestHandler::startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) { if ( !ba ) { return false; } if ( ba->size() < 1 ) { return false; } QString format; if ( infoFormat == QLatin1String( "GeoJSON" ) ) format = QStringLiteral( "text/plain" ); else format = QStringLiteral( "text/xml" ); setInfoFormat( format ); appendBody( *ba ); // Streaming sendResponse(); return true; }
int QgsSOAPRequestHandler::setSOAPWithAttachments( QImage* img ) { QgsDebugMsg( "Entering." ); //create response xml document QDomDocument xmlResponse; //response xml, save this into mimeString QDomElement envelopeElement = xmlResponse.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "Envelope" ); xmlResponse.appendChild( envelopeElement ); QDomElement bodyElement = xmlResponse.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "Body" ); envelopeElement.appendChild( bodyElement ); QDomElement getMapResponseElement = xmlResponse.createElementNS( "http://www.eu-orchestra.org/services/ms", "getMapResponse" ); bodyElement.appendChild( getMapResponseElement ); QDomElement returnElement = xmlResponse.createElementNS( "http://www.eu-orchestra.org/services/ms", "return" ); returnElement.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" ); returnElement.setAttribute( "xsi:type", "OA_ImageDocument" ); returnElement.setAttribute( "href", "image@mapservice" ); getMapResponseElement.appendChild( returnElement ); //create image buffer QByteArray ba; QBuffer buffer( &ba ); buffer.open( QIODevice::WriteOnly ); img->save( &buffer, mFormat.toLocal8Bit().data(), -1 ); // writes image into ba QByteArray xmlByteArray = xmlResponse.toString().toLocal8Bit(); // Set headers setHeader( "MIME-Version", "1.0" ); setHeader( "Content-Type", "Multipart/Related; boundary=\"MIME_boundary\"; type=\"text/xml\"; start=\"<xml@mapservice>\"" ); // Start body appendBody( "--MIME_boundary\r\n" ); appendBody( "Content-Type: text/xml\n" ); appendBody( "Content-ID: <xml@mapservice>\n" ); appendBody( "\n" ); appendBody( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); appendBody( xmlByteArray ); appendBody( "\n" ); appendBody( "\r\n" ); appendBody( "--MIME_boundary\r\n" ); if ( mFormat == "JPG" ) { appendBody( "Content-Type: image/jpg\n" ); } else if ( mFormat == "PNG" ) { appendBody( "Content-Type: image/png\n" ); } appendBody( "Content-Transfer-Encoding: binary\n" ); appendBody( "Content-ID: <image@mapservice>\n" ); appendBody( "\n" ); appendBody( ba ); appendBody( "\r\n" ); appendBody( "--MIME_boundary\r\n" ); return 0; }