summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkreply.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qhttpnetworkreply.cpp')
-rw-r--r--src/network/access/qhttpnetworkreply.cpp49
1 files changed, 42 insertions, 7 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 9dbc11d..ba429fd 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -187,6 +187,10 @@ bool QHttpNetworkReply::isFinished() const
return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState;
}
+bool QHttpNetworkReply::isPipeliningUsed() const
+{
+ return d_func()->pipeliningUsed;
+}
QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
@@ -195,6 +199,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
chunkedTransferEncoding(0),
currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
autoDecompress(false), responseData(), requestIsPrepared(false)
+ ,pipeliningUsed(false)
{
}
@@ -418,20 +423,26 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket)
}
bool ok = parseStatus(fragment);
state = ReadingHeaderState;
- fragment.clear(); // next fragment
-
- if (!ok)
+ fragment.clear();
+ if (!ok) {
return -1;
+ }
break;
} else {
c = 0;
- bytes += socket->read(&c, 1);
+ int haveRead = socket->read(&c, 1);
+ if (haveRead == -1)
+ return -1;
+ bytes += haveRead;
fragment.append(c);
}
// is this a valid reply?
if (fragment.length() >= 5 && !fragment.startsWith("HTTP/"))
+ {
+ fragment.clear();
return -1;
+ }
}
@@ -566,7 +577,6 @@ qint64 QHttpNetworkReplyPrivate::readBodyFast(QAbstractSocket *socket, QByteData
if (contentRead + haveRead == bodyLength) {
state = AllDoneState;
- socket->readAll(); // Read the rest to clean (CRLF) ### will break pipelining
}
contentRead += haveRead;
@@ -586,8 +596,6 @@ qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QByteDataBuff
} else {
bytes += readReplyBodyRaw(socket, out, socket->bytesAvailable());
}
- if (state == AllDoneState)
- socket->readAll(); // Read the rest to clean (CRLF) ### will break pipelining
contentRead += bytes;
return bytes;
}
@@ -715,6 +723,33 @@ void QHttpNetworkReplyPrivate::appendCompressedReplyData(QByteDataBuffer &data)
}
+bool QHttpNetworkReplyPrivate::shouldEmitSignals()
+{
+ // for 401 & 407 don't emit the data signals. Content along with these
+ // responses are send only if the authentication fails.
+ return (statusCode != 401 && statusCode != 407);
+}
+
+bool QHttpNetworkReplyPrivate::expectContent()
+{
+ // check whether we can expect content after the headers (rfc 2616, sec4.4)
+ if ((statusCode >= 100 && statusCode < 200)
+ || statusCode == 204 || statusCode == 304)
+ return false;
+ if (request.operation() == QHttpNetworkRequest::Head)
+ return !shouldEmitSignals();
+ if (contentLength() == 0)
+ return false;
+ return true;
+}
+
+void QHttpNetworkReplyPrivate::eraseData()
+{
+ compressedData.clear();
+ responseData.clear();
+}
+
+
// SSL support below
#ifndef QT_NO_OPENSSL