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#ifndef QNETWORKREQUEST_P_H
5#define QNETWORKREQUEST_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include "qnetworkrequest.h"
20#include "QtCore/qbytearray.h"
21#include "QtCore/qlist.h"
22#include "QtCore/qhash.h"
23#include "QtCore/qshareddata.h"
24#include "QtCore/qsharedpointer.h"
25#include "QtCore/qpointer.h"
26
27QT_BEGIN_NAMESPACE
28
29// this is the common part between QNetworkRequestPrivate, QNetworkReplyPrivate and QHttpPartPrivate
30class QNetworkHeadersPrivate
31{
32public:
33 typedef QPair<QByteArray, QByteArray> RawHeaderPair;
34 typedef QList<RawHeaderPair> RawHeadersList;
35 typedef QHash<QNetworkRequest::KnownHeaders, QVariant> CookedHeadersMap;
36 typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap;
37
38 RawHeadersList rawHeaders;
39 CookedHeadersMap cookedHeaders;
40 AttributesMap attributes;
41 QPointer<QObject> originatingObject;
42
43 RawHeadersList::ConstIterator findRawHeader(const QByteArray &key) const;
44 RawHeadersList allRawHeaders() const;
45 QList<QByteArray> rawHeadersKeys() const;
46 void setRawHeader(const QByteArray &key, const QByteArray &value);
47 void setAllRawHeaders(const RawHeadersList &list);
48 void setCookedHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
49
50 static QDateTime fromHttpDate(const QByteArray &value);
51 static QByteArray toHttpDate(const QDateTime &dt);
52
53private:
54 void setRawHeaderInternal(const QByteArray &key, const QByteArray &value);
55 void parseAndSetHeader(const QByteArray &key, const QByteArray &value);
56};
57
58Q_DECLARE_TYPEINFO(QNetworkHeadersPrivate::RawHeaderPair, Q_RELOCATABLE_TYPE);
59
60QT_END_NAMESPACE
61
62
63#endif
64

source code of qtbase/src/network/access/qnetworkrequest_p.h