Exemplo n.º 1
0
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();
    }
}
Exemplo n.º 2
0
void
SmugMug::WebService::_slotHttpReadyRead (const QHttpResponseHeader &resp) {

    QHttp &theHttp = (_ssl ? _https : _http);

    if (resp.statusCode () != 200) {

        QString msg = QString ("[%1] %2").arg (resp.statusCode ()).arg (resp.reasonPhrase ());
        _logHttpError (msg);
        theHttp.abort();
    }
    else {

        const qint64 MaxLen (theHttp.bytesAvailable ());

        if (MaxLen) {

            char *buffer = new char [MaxLen+1];
            memset (buffer, 0, MaxLen+1);

            qint64 count = theHttp.read (buffer, MaxLen);

            _dataIn.append (buffer);

            delete [] buffer;
            buffer = 0;

            qDebug () << "Read Ready: " << count << " of " << MaxLen;
        }
    }
}
Exemplo n.º 3
0
void FlexWatchCam::httpReadyRead(const QHttpResponseHeader & resp)
{
  if(resp.statusCode() != 200)
    QMessageBox::warning(0, "Error", tr("StatusCode = %1").arg(resp.statusCode()));
  else {
    QByteArray array = http_.readAll();
    processing(array);
  }
}
Exemplo n.º 4
0
void MythHttpHandler::ResponseHeaderReceived(const QHttpResponseHeader &resp)
{
    QMutexLocker locker(&m_lock);

    LOG(VB_NETWORK, LOG_DEBUG, LOC +
        QString("ResponseHeaderReceived(%1,%2) url: %3")
            .arg(resp.statusCode()).arg(resp.reasonPhrase())
            .arg(m_cur_url.toString()));
    m_cur_status_id  = resp.statusCode();
    m_cur_status_str = resp.reasonPhrase();
}
Exemplo n.º 5
0
void HttpFileReceiver::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
    if ( responseHeader.statusCode() >= 400 )
    {
        fetcher->httpRequestAborted = true;
        QString detailedError( "HttpFileReceiver::readReasponseHeader:- status code: %1 "
                               "reason phrase: %2" );
        detailedError = detailedError.arg( responseHeader.statusCode() )
                                     .arg( responseHeader.reasonPhrase() );
        fetcher->error = detailedError; 
    }
}
Exemplo n.º 6
0
void BrisaMSearchClientCP::datagramReceived() {
    while (udpListener->hasPendingDatagrams()) {

        QByteArray Datagram;

        Datagram.resize(udpListener->pendingDatagramSize());
        udpListener->readDatagram(Datagram.data(), Datagram.size());

        QString temp(Datagram);
        QHttpResponseHeader *response = new QHttpResponseHeader(temp);

        if (response->statusCode() == 200) {
            QString usn = response->value("usn");
            if (usn.startsWith("uuid:")) {
                qDebug() << "BrisaMSearch received MSearch answer from "  << usn << "";
                emit msearchResponseReceived(response->value("usn"),
                                             response->value("location"),
                                             response->value("st"),
                                             response->value("ext"),
                                             response->value("server"),
                                             response->value("cache-control"));
            } else {
                qDebug() << "BrisaMSearch received MSearch from " << response->value("location")
                         << " but it does not start with string \"uuid:\". USN field is " << usn;
            }
        }

        delete response;
    }
}
Exemplo n.º 7
0
void HttpGet::httpResponseHeader(const QHttpResponseHeader &resp)
{
    // if there is a network error abort all scheduled requests for
    // this download
    m_response = resp.statusCode();
   
    // 301 -- moved permanently
    // 302 -- found
    // 303 -- see other
    // 307 -- moved temporarily
    // in all cases, header: location has the correct address so we can follow.
    if(m_response == 301 || m_response == 302 || m_response == 303 || m_response == 307) {
        //abort without sending any signals
        http.blockSignals(true);
        http.abort();
        http.blockSignals(false);
        // start new request with new url
        qDebug() << "[HTTP] response =" << m_response << "- following";
        getFile(resp.value("location") + m_query);
    }
    else if(m_response != 200) {
        // all other errors are fatal.
        http.abort();
        qDebug() << "[HTTP] Response error:" << m_response << resp.reasonPhrase();
    }

}
Exemplo n.º 8
0
/**
 * Checks for the status code and aborts the request if needed.
 */
void TextBrowser::onResponseHeaderReceived(const QHttpResponseHeader &responseHeader)
{
  if (responseHeader.statusCode() != 200) {
    stateChanged(tr("Download failed: %1.").arg(responseHeader.reasonPhrase()));
    d->http->abort();
  }
}
Exemplo n.º 9
0
void DJDownloadManager::httpReadyRead ( const QHttpResponseHeader & response )
{
	int status	= response.statusCode();
	djDebug() << "httpReadyRead" << status << m_file->fileName();
	if ( !m_file->fileName().isEmpty() )
		m_file->write( m_http->readAll() );
}
void DBoxFE_ProfileWizard::readResponseHeader( const QHttpResponseHeader &responseHeader ) {
  if ( responseHeader.statusCode() != 200 ) {
    QMessageBox::information( this, dbfe->winTitle(), tr( "Download failed: %1." ).arg( responseHeader.reasonPhrase() ) );
    httpRequestAborted = true;
    m_http->abort();
    return ;
  }
}
Exemplo n.º 11
0
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();
}
Exemplo n.º 12
0
void FileDownloader::readResponseHeader(const QHttpResponseHeader &responseHeader) {
	if (responseHeader.statusCode() != 200) {
		emit downloadFailed(responseHeader.reasonPhrase());
		http_request_aborted = true;
		hide();
		http->abort();
		return;
	}
}
Exemplo n.º 13
0
void UtubeData::readData(const QHttpResponseHeader &resp) {
  if (resp.statusCode() != 200) {
    mHttp->abort();
    qDebug() << "UTUBE: Error." << endl;
  } else {
    mXml.addData(mHttp->readAll());
    parseXml();
  }
}
Exemplo n.º 14
0
void RSSFetcher::readData(const QHttpResponseHeader &resp)
{
    if (resp.statusCode() != 200)
        m_http.abort();
    else {
        m_xml.addData(m_http.readAll());
        parseXml();
    }
}
Exemplo n.º 15
0
void ArchLinuxNewsReader::readData(const QHttpResponseHeader &resp)
{
    if (resp.statusCode() != 200)
        http->abort();
    else {
        xml.addData(http->readAll());
        parseXml();
    }
}
Exemplo n.º 16
0
void RSSListing::readData(const QHttpResponseHeader &resp)
{
    if (resp.statusCode() != 200)
        http.abort();
    else {
        xml.addData(http.readAll());
        parseXml();
    }
}
Exemplo n.º 17
0
void HttpEngine::handleUploadHeaders(QHttpResponseHeader header)
{
	if(header.statusCode() != 200)
		throw header.reasonPhrase();
	
	qint64 clen = header.value("content-length").toLongLong();
	while(m_strResponse.size() < clen)
		m_strResponse += m_pRemote->read(1024);
	emit finished(false);
}
Exemplo n.º 18
0
void HttpThread::readResponseHeader(QHttpResponseHeader const& responseHeader)
{
qDebug() << "httpResponseHeader" << responseHeader.statusCode();
    switch (responseHeader.statusCode()) {
       case 200:   // Ok
       case 301:   // Moved Permanently
       case 302:   // Found
       case 303:   // See Other
       case 307:   // Temporary Redirect
           break;  // these are not error conditions

       default:
          m_errorMessage = "HTTP request failed: " + responseHeader.reasonPhrase();
qDebug() << "Error message:" << m_errorMessage;
          m_terminate = true;
          m_httpActive = false;
          m_http->abort();
    }
}
Exemplo n.º 19
0
void
SmugMug::WebService::_slotDownloadHttpReadyRead (const QHttpResponseHeader &resp) {

    if (_downloadId) {

        qDebug () << "_slotDownloadHttpReadyRead" << resp.statusCode () << resp.reasonPhrase ();

        if (resp.statusCode () != 200) {

            qWarning () << "---- Download Http Error -----------------------------------";
            qWarning () << "Response Reason:" << resp.reasonPhrase () << endl
                        << "Request:" << _downloadHttp.currentRequest ().path () << endl
                        << "Bytes returned:" << _downloadHttp.bytesAvailable () << endl
                        << "-----------------------------------------------------" << endl;

            _downloadAborted = true;
            _downloadHttp.abort();
        }
    }
}
Exemplo n.º 20
0
void Gmail::readData(const QHttpResponseHeader &resp)
{
    if (resp.statusCode() != 200)
    {
        http.abort();
        //emit probleme de connection
    }
    else {
        xml.addData(http.readAll());
        getEmails();
    }
}
Exemplo n.º 21
0
/*---------------------------------------------------------------------------*/
QVariant HttpRecognizer::comment( IConnection* connection )
{
	Q_ASSERT (connection);
	if (!mConnections.contains( connection->networkInfo() ))
		return "No comment yet";

	const HttpConnection con = mConnections.value( connection->networkInfo() );
	const QHttpRequestHeader request = con.lastRequestHeader();
	const QHttpResponseHeader response = con.lastResponseHeader();

	return request.method() + " " + request.value( "host" ) + request.path()
		+ (response.isValid() ? "\nHTTP " + QString::number( response.statusCode() ) + " " + response.reasonPhrase() : "" );
}
Exemplo n.º 22
0
void SimpleHttp::readResponseHeader(const QHttpResponseHeader &responseHeader) {
	qDebug("SimpleHttp::readResponseHeader: statusCode: %d", responseHeader.statusCode());

	if (responseHeader.statusCode() == 301)  {
		QString new_url = responseHeader.value("Location");
		qDebug("SimpleHttp::readResponseHeader: Location: '%s'", new_url.toLatin1().constData());
		download(new_url);
	}
	else
	if (responseHeader.statusCode() == 302)  {
		QString location = responseHeader.value("Location");
		qDebug("SimpleHttp::readResponseHeader: Location: '%s'", location.toLatin1().constData());
		/* http_get_id = get( location ); */
		download(location);
	}
	else
	if (responseHeader.statusCode() != 200) {
		qDebug("SimpleHttp::readResponseHeader: error: '%s'", responseHeader.reasonPhrase().toLatin1().constData());
		emit downloadFailed(responseHeader.reasonPhrase());
		abort();
	}
}
Exemplo n.º 23
0
void DownloadHandler::readResponseHeader( const QHttpResponseHeader &responseHeader )
{
   const QString contentType("Content-Type");
#if USE_TRACE
TRACESTART(DownloadHandler::readResponseHeader)
#endif
   if( (responseHeader.statusCode() >= 300) && (responseHeader.statusCode() < 400) )
   {
      TheMagic *magic = new TheMagic( *mpTheMagic );
      magic->mURL = responseHeader.value("location");
      mpMagicQueue->addMagic( magic );
      mpTheMagic->fail();
   }
   else if( responseHeader.statusCode() != 200 )
   {
      errorMessage( mpTheMagic->mURL + ":" + QString::number( responseHeader.statusCode() ) +
                    " " + responseHeader.reasonPhrase() );
      mpTheMagic->fail();
   }

   if( responseHeader.hasContentType() )
   {
      mpTheMagic->setContentType( responseHeader.contentType() );
   }

   const QString setCookie("Set-Cookie");
   QList<QPair<QString, QString> > values( responseHeader.values() );
   for( int i = 0; i < values.size(); i++ )
   {
      if( !QString::compare(values.at(i).first, setCookie, Qt::CaseInsensitive) )
      {
#if USE_TRACE
TRACEMSG << values.at(i).second;
#endif
         mCookieJar.store( values.at(i).second );
      }
   }
}
Exemplo n.º 24
0
void CHttpImageDownloader::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
    switch (responseHeader.statusCode())
    {
    case 200:                   // Ok
    case 301:                   // Moved Permanently
    case 302:                   // Found
    case 303:                   // See Other
    case 307:                   // Temporary Redirect
        // these are not error conditions
        break;

        http->abort();
    }
}
Exemplo n.º 25
0
void OracleImporter::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
	switch (responseHeader.statusCode()) {
		case 200:
		case 301:
		case 302:
		case 303:
		case 307:
			break;
		default:
			QMessageBox::information(0, tr("HTTP"), tr("Download failed: %1.").arg(responseHeader.reasonPhrase()));
			http->abort();
			deleteLater();
	}
}
Exemplo n.º 26
0
void
Reader::loginHeaderReceived( const QHttpResponseHeader & resp )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL(  responseHeaderReceived( const QHttpResponseHeader & ) )
            , this, SLOT( loginHeaderReceived( const QHttpResponseHeader & ) ) );
    if( resp.statusCode() == 401 /*authorization required*/)
    {
        emit passwordRequired();
        http->deleteLater();
        return;
    }
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
}
Exemplo n.º 27
0
void HttpCore::readResponseHeader(const QHttpResponseHeader &responseHeader){
    switch (responseHeader.statusCode()) {
         case 200:                   // Ok
         case 301:                   // Moved Permanently
         case 303:                   // See Other
         case 307:                   // Temporary Redirect
             // these are not error conditions
             break;

         default:
             emit(requestError(tr("Download failed: %1.").arg(responseHeader.reasonPhrase())));;
             this->aborted=true;
             http->abort();
         }
    return;
}
Exemplo n.º 28
0
void Network::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
	switch (responseHeader.statusCode()) {
	case 200:                   // Ok
	case 301:                   // Moved Permanently
	case 302:                   // Found
	case 303:                   // See Other
	case 307:                   // Temporary Redirect
		// these are not error conditions
		break;
	default:
		//QMessageBox::information(this, tr("HTTP"), tr("Download failed: %1.").arg(responseHeader.reasonPhrase()));
		qDebug("Download failed.");
		httpRequestAborted = true;
		http->abort();
	}
}
Exemplo n.º 29
0
//! [1]
void RSSListing::readData(const QHttpResponseHeader &resp)
{
    bool ok;

    if (resp.statusCode() != 200)
        http.abort();
    else {
        xmlInput.setData(http.readAll());

        if (newInformation) {
            ok = xmlReader.parse(&xmlInput, true);
            newInformation = false;
        }
        else
            ok = xmlReader.parseContinue();

        if (!ok)
            http.abort();
    }
}
Exemplo n.º 30
0
void PluginGmail::readData(const QHttpResponseHeader &resp)
{
	Bunny * bunny = BunnyManager::GetBunny(this, http.property("BunnyID").toByteArray());

	if (resp.statusCode() != 200)
	{
		http.abort();
		LogWarning("Connection error");
	}
	else
	{
		xml.addData(http.readAll());

		while (!xml.atEnd()) 
		{
			xml.readNext();
			if (xml.isStartElement())
			{
				currentTag = xml.name().toString();
			}
			else if (xml.isCharacters() && !xml.isWhitespace())
			{
				if (currentTag == "fullcount")
				{
					bool ok;
					emailsCount = xml.text().toString().toInt(&ok);
					if (emailsCount > 0)
					{
						bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 1));

					}
					else
					{
						bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 0));
					}
				}
			}
    		}
	}
}