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