void ownCloudInfo::qhttpResponseHeaderReceived(const QHttpResponseHeader& header) { qDebug() << "Resp:" << header.toString(); if (header.statusCode() == 201) emit webdavColCreated( QNetworkReply::NoError ); else qDebug() << "http request failed" << header.toString(); }
void FeedFetcher::readData(const QHttpResponseHeader& response_header) { if(!impl_->current_feed_.get()) return; int statusCode = response_header.statusCode(); qDebug() << statusCode; if (statusCode == 200) { //TODO in order to insert CDATA to invalid XML atom, //we need capture data of full page bytes_.append(impl_->http_->readAll()); // qDebug() << bytes_.size() << " bytes received."; // insert CDATA FLAG if not exists } else if ((statusCode >300 || statusCode <300) && (response_header.hasKey("location") || response_header.hasKey("Location"))) { qDebug()<<response_header.statusCode(); QUrl location = QUrl(response_header.value("location")); if (location.isEmpty()) { location = QUrl(response_header.value("Location")); } qDebug() << location; impl_->http_.get()->setHost(location.host(),80); impl_->connection_id_ = impl_->http_.get()->get(location.toString()); } else if (statusCode == 404) { //NOTE: Do Nothing qDebug() << "404 !!"; } else { qDebug() << "Received non-200 response code: " << statusCode << response_header.toString(); } }
void RequestParser::serveFile(QString filename) { QFile file(filename); QHttpResponseHeader header; if (file.open(QIODevice::ReadOnly)) { header.setStatusLine(200, "OK", 1,0); QByteArray data = file.readAll(); header.setContentLength(data.length()); emit write(header.toString().toUtf8()); emit write("\r\n"); emit write(data); emit close(); } else { header.setStatusLine(404, "NOT FOUND", 1,0); emit write(header.toString().toUtf8()); emit close(); } }
void RequestParser::serveIndex() { QHttpResponseHeader header; header.setStatusLine(200, "OK", 1,1); QByteArray buffer = "<HTML><BODY>Index</BODY></HTML>"; header.setContentLength(buffer.length()); header.setContentType("text/html"); emit write(header.toString().toUtf8()); emit write(buffer); exit(0); }
/** This method will ... * @param [inout] reqData: ... @param [out] error: error description for an invalid request * @return: can we serve this request? *******************************************************************************/ std::string CuteHttpParser::makeOkResp(CuteSrvRequest& reqData, const std::string& respStr) { QHttpResponseHeader ok; ok.setStatusLine(200); ok.addValue("Content-Type", "text/html"); ok.setContentLength(respStr.size()); string resp = ok.toString().toLatin1().constData();; // add content resp.append(respStr); resp.append(c_httpLineEnd); return resp; }
/** This method will ... * @param [inout] reqData: ... @param [out] error: error description for an invalid request * @return: can we serve this request? *******************************************************************************/ std::string CuteHttpParser::makeErrorResp(CuteSrvRequest& reqData, int errCode, const std::string& errStr) { // format err string: // OPEN TODO:: error pages??? string errPage("<html><body><h2>"); errPage.append(errStr); errPage.append("</h2></body></html>"); QHttpResponseHeader err; err.setStatusLine(errCode, ""); err.addValue("Content-Type", "text/html"); err.setContentLength(errPage.size()); string resp = err.toString().toLatin1().constData(); // add content resp.append(errPage); resp.append(c_httpLineEnd); return resp; }
void RequestParser::httpResponseHead(QHttpResponseHeader header) { m_responseHttpVersion = header.majorVersion() + header.minorVersion() / 10.0; emit write(header.toString().toUtf8()); }
void RequestParser::httpResponse(QHttpResponseHeader header, QByteArray content) { m_responseHttpVersion = header.majorVersion() + header.minorVersion() / 10.0; emit write(header.toString().toUtf8()); emit write(content); }
/*! * \reimp */ void QxtHttpServerConnector::writeHeaders(QIODevice* device, const QHttpResponseHeader& header) { if (header.majorVersion() == 0) return; // 0.9 doesn't have headers device->write(header.toString().toUtf8()); }
void QGeniePlugin_Basic_Remote_ReadyShare::readyRead ( const QHttpResponseHeader & resp ) { qDebug()<<"QHttpResponseHeader is " +resp.toString(); QByteArray bta=http->readAll(); qDebug()<<"http->readAll() is " <<bta.data(); QString strTemp(bta.data()); if (strTemp.indexOf("Timeout")>-1) { btnContinue->setEnabled(true); btnBack->setEnabled(true); qPrg->stopAnimation(); timerHttp->stop(); iTimerCount=0; rdoBasic->setEnabled(true); rdoRemote->setEnabled(true); iErrorNum=1; lblErrorString->setText(strTimeout); return; } if (strTemp.indexOf("unregister_user")>-1) { strRegUser=getUser(strTemp); strRegPwd=getPassword(strTemp); btnContinue->setEnabled(true); btnBack->setEnabled(true); qPrg->stopAnimation(); timerHttp->stop(); iTimerCount=0; rdoBasic->setEnabled(true); rdoRemote->setEnabled(true); emit RegisterOk( strRegUser, strRegPwd); } if (strTemp.indexOf("value=\"register_user\"")>-1) { btnContinue->setEnabled(true); btnBack->setEnabled(true); qPrg->stopAnimation(); timerHttp->stop(); iTimerCount=0; rdoBasic->setEnabled(true); rdoRemote->setEnabled(true); emit RegisterNotYet(); } }