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
11QT_BEGIN_NAMESPACE
12
13namespace Http2
14{
15
16Stream::Stream()
17{
18}
19
20Stream::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
28Stream::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
37QHttpNetworkReply *Stream::reply() const
38{
39 return httpPair.second;
40}
41
42const QHttpNetworkRequest &Stream::request() const
43{
44 return httpPair.first;
45}
46
47QHttpNetworkRequest &Stream::request()
48{
49 return httpPair.first;
50}
51
52QHttpNetworkRequest::Priority Stream::priority() const
53{
54 return httpPair.first.priority();
55}
56
57uchar 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
70QNonContiguousByteDevice *Stream::data() const
71{
72 return httpPair.first.uploadByteDevice();
73}
74
75} // namespace Http2
76
77QT_END_NAMESPACE
78

source code of qtbase/src/network/access/http2/http2streams.cpp