Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

qint64 QHttp::read ( char *  data,
qint64  maxlen 
)

Reads maxlen bytes from the response content into data and returns the number of bytes read. Returns -1 if an error occurred.

See also:
get() post() request() readyRead() bytesAvailable() readAll()

Definition at line 1751 of file qhttp.cpp.

Referenced by readAll().

{
    Q_D(QHttp);
    if (data == 0 && maxlen != 0) {
        qWarning("QHttp::read: Null pointer error");
        return -1;
    }
    if (maxlen >= d->rba.size())
        maxlen = d->rba.size();
    int readSoFar = 0;
    while (!d->rba.isEmpty() && readSoFar < maxlen) {
        int nextBlockSize = d->rba.nextDataBlockSize();
        int bytesToRead = qMin<qint64>(maxlen - readSoFar, nextBlockSize);
        memcpy(data + readSoFar, d->rba.readPointer(), bytesToRead);
        d->rba.free(bytesToRead);
        readSoFar += bytesToRead;
    }

    d->bytesDone += maxlen;
#if defined(QHTTP_DEBUG)
    qDebug("QHttp::read(): read %lld bytes (%lld bytes done)", maxlen, d->bytesDone);
#endif
    return maxlen;
}


Generated by  Doxygen 1.6.0   Back to index