| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | // Qt-Security score:critical reason:network-protocol |
| 4 | |
| 5 | #include "http2streams_p.h" |
| 6 | |
| 7 | #include "private/qhttp2protocolhandler_p.h" |
| 8 | #include "private/qhttpnetworkreply_p.h" |
| 9 | |
| 10 | #include <QtCore/qdebug.h> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | namespace Http2 |
| 15 | { |
| 16 | |
| 17 | Stream::Stream() |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | Stream::Stream(const HttpMessagePair &message, quint32 id, qint32 sendSize, qint32 recvSize) |
| 22 | : httpPair(message), |
| 23 | streamID(id), |
| 24 | sendWindow(sendSize), |
| 25 | recvWindow(recvSize) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | Stream::Stream(const QString &cacheKey, quint32 id, qint32 recvSize) |
| 30 | : streamID(id), |
| 31 | // sendWindow is 0, this stream only receives data |
| 32 | recvWindow(recvSize), |
| 33 | state(remoteReserved), |
| 34 | key(cacheKey) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | QHttpNetworkReply *Stream::reply() const |
| 39 | { |
| 40 | return httpPair.second; |
| 41 | } |
| 42 | |
| 43 | const QHttpNetworkRequest &Stream::request() const |
| 44 | { |
| 45 | return httpPair.first; |
| 46 | } |
| 47 | |
| 48 | QHttpNetworkRequest &Stream::request() |
| 49 | { |
| 50 | return httpPair.first; |
| 51 | } |
| 52 | |
| 53 | QHttpNetworkRequest::Priority Stream::priority() const |
| 54 | { |
| 55 | return httpPair.first.priority(); |
| 56 | } |
| 57 | |
| 58 | uchar Stream::weight() const |
| 59 | { |
| 60 | switch (priority()) { |
| 61 | case QHttpNetworkRequest::LowPriority: |
| 62 | return 0; |
| 63 | case QHttpNetworkRequest::NormalPriority: |
| 64 | return 127; |
| 65 | case QHttpNetworkRequest::HighPriority: |
| 66 | default: |
| 67 | return 255; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | QNonContiguousByteDevice *Stream::data() const |
| 72 | { |
| 73 | return httpPair.first.uploadByteDevice(); |
| 74 | } |
| 75 | |
| 76 | } // namespace Http2 |
| 77 | |
| 78 | QT_END_NAMESPACE |
| 79 |
