Guest User

Untitled

a guest
Jul 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.67 KB | None | 0 0
  1. diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
  2. index 17bd9c0..d93abb1 100644
  3. --- a/src/network/access/qhttpnetworkreply.cpp
  4. +++ b/src/network/access/qhttpnetworkreply.cpp
  5. @@ -257,7 +257,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
  6.        chunkedTransferEncoding(false),
  7.        connectionCloseEnabled(true),
  8.        forceConnectionCloseEnabled(false),
  9. -      currentChunkSize(0), currentChunkRead(0), connection(0),
  10. +      currentChunkSize(0), currentChunkRead(0), lastChunkRead(false), connection(0),
  11.        autoDecompress(false), responseData(), requestIsPrepared(false)
  12.        ,pipeliningUsed(false), downstreamLimited(false)
  13.        ,userProvidedDownloadBuffer(0)
  14. @@ -277,6 +277,7 @@ void QHttpNetworkReplyPrivate::clearHttpLayerInformation()
  15.      totalProgress = 0;
  16.      currentChunkSize = 0;
  17.      currentChunkRead = 0;
  18. +    lastChunkRead = false;
  19.      connectionCloseEnabled = true;
  20.  #ifndef QT_NO_COMPRESS
  21.      if (autoDecompress)
  22. @@ -721,7 +722,7 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QAbstractSocket *socket, Q
  23.  {
  24.      qint64 bytes = 0;
  25.      while (socket->bytesAvailable()) {
  26. -        if (currentChunkRead >= currentChunkSize) {
  27. +        if (!lastChunkRead && currentChunkRead >= currentChunkSize) {
  28.              // For the first chunk and when we're done with a chunk
  29.              currentChunkSize = 0;
  30.              currentChunkRead = 0;
  31. @@ -744,13 +745,16 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QAbstractSocket *socket, Q
  32.                  break;
  33.          }
  34.          // if the chunk size is 0, end of the stream
  35. -        if (currentChunkSize == 0) {
  36. +        if (currentChunkSize == 0 || lastChunkRead) {
  37. +            lastChunkRead = true;
  38.              // try to read the "\r\n" after the chunk
  39.              char crlf[2];
  40.              qint64 haveRead = socket->read(crlf, 2);
  41.              if (haveRead > 0)
  42.                  bytes += haveRead;
  43. -            state = AllDoneState;
  44. +
  45. +            if ((haveRead == 2 && crlf[0] == '\r' && crlf[1] == '\n') || (haveRead == 1 && crlf[0] == '\n'))
  46. +                state = AllDoneState;
  47.              break;
  48.          }
  49.  
  50. diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
  51. index 04e4569..06cac75 100644
  52. --- a/src/network/access/qhttpnetworkreply_p.h
  53. +++ b/src/network/access/qhttpnetworkreply_p.h
  54. @@ -219,6 +219,7 @@ public:
  55.      bool forceConnectionCloseEnabled;
  56.      qint64 currentChunkSize;
  57.      qint64 currentChunkRead;
  58. +    bool lastChunkRead;
  59.      QPointer<QHttpNetworkConnection> connection;
  60.      QPointer<QHttpNetworkConnectionChannel> connectionChannel;
Add Comment
Please, Sign In to add comment