Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrestaccessmanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QRESTACCESSMANAGER_P_H
5#define QRESTACCESSMANAGER_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 "qrestaccessmanager.h"
19#include "private/qobject_p.h"
20
21#include <QtNetwork/qnetworkaccessmanager.h>
22
23#include <QtCore/qjsonarray.h>
24#include <QtCore/qhash.h>
25#include <QtCore/qjsondocument.h>
26#include <QtCore/qjsonobject.h>
27#include <QtCore/qxpfunctional.h>
28
30
31class QRestReply;
33{
34public:
37
41
45 {
46 if (!qnam)
47 return warnNoAccessManager();
49 QNetworkReply *reply = requestOperation(qnam);
50 return createActiveRequest(reply, context, slot);
51 }
52
54 const QNetworkRequest &,
55 const QByteArray &) const>;
56 QNetworkReply *executeRequest(ReqOpRefJson requestOperation, const QJsonDocument &jsonDoc,
59 {
60 if (!qnam)
61 return warnNoAccessManager();
64 auto h = req.headers();
67 QLatin1StringView{"application/json"});
68 }
69 req.setHeaders(std::move(h));
70 QNetworkReply *reply = requestOperation(qnam, req, jsonDoc.toJson(QJsonDocument::Compact));
71 return createActiveRequest(reply, context, slot);
72 }
73
74 void verifyThreadAffinity(const QObject *contextObject);
77
78 struct CallerInfo {
79 QPointer<const QObject> contextObject = nullptr;
81 };
82 QHash<QNetworkReply*, CallerInfo> activeRequests;
83
86 Q_DECLARE_PUBLIC(QRestAccessManager)
87};
88
90
91#endif
\inmodule QtCore
Definition qbytearray.h:57
Q_NETWORK_EXPORT bool append(QAnyStringView name, QAnyStringView value)
Appends a header entry with name and value and returns true if successful.
\inmodule QtCore\reentrant
The QNetworkAccessManager class allows the application to send network requests and receive replies.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
void setHeaders(const QHttpHeaders &newHeaders)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QHttpHeaders headers() const
\inmodule QtCore
Definition qobject.h:103
QNetworkReply * createActiveRequest(QNetworkReply *reply, const QObject *contextObject, QtPrivate::QSlotObjectBase *slot)
Q_DECL_COLD_FUNCTION QNetworkReply * warnNoAccessManager()
QHash< QNetworkReply *, CallerInfo > activeRequests
QNetworkReply * executeRequest(ReqOpRefJson requestOperation, const QJsonDocument &jsonDoc, const QNetworkRequest &request, const QObject *context, QtPrivate::QSlotObjectBase *slot)
QNetworkAccessManager * qnam
void handleReplyFinished(QNetworkReply *reply)
void verifyThreadAffinity(const QObject *contextObject)
QNetworkReply * executeRequest(ReqOpRef requestOperation, const QObject *context, QtPrivate::QSlotObjectBase *slot)
The QRestAccessManager is a convenience wrapper for QNetworkAccessManager.
QRestReply is a convenience wrapper for QNetworkReply.
Definition qrestreply.h:24
Combined button and popup list for selecting options.
static void * context
#define Q_DECL_COLD_FUNCTION
GLfloat GLfloat GLfloat GLfloat h
QNetworkRequest request(url)
QNetworkReply * reply