KItinerary

httpresponse.h
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KITINERARY_HTTPRESPONSE_H
7#define KITINERARY_HTTPRESPONSE_H
8
9#include "kitinerary_export.h"
10
11#include <QDateTime>
12#include <QExplicitlySharedDataPointer>
13#include <QMetaType>
14#include <QUrl>
15
16class QJsonObject;
17class QNetworkReply;
18
19namespace KItinerary {
20
21class HttpResponsePrivate;
22
23/**
24 * Container for an HTTP response to be passed into the extractor engine.
25 * This is primarily needed for extracting data from arbitrary API responses
26 * or for custom website extractors, as we cannot trigger extractor scripts
27 * on HTTP request or response parameters (such as the URL) otherwise.
28 *
29 * For operational use this can be created from a QNetworkReply, the support for
30 * HAR files is mainly intended for development use.
31 */
32class KITINERARY_EXPORT HttpResponse
33{
34 Q_GADGET
35 Q_PROPERTY(QUrl url READ url)
36 Q_PROPERTY(QByteArray content READ content)
37 Q_PROPERTY(QDateTime requestDateTime READ requestDateTime)
38
39public:
43 HttpResponse& operator=(const HttpResponse&);
44 operator QVariant() const;
45
46 QUrl url() const;
47 QByteArray content() const;
48 QDateTime requestDateTime() const;
49
50 /** Create a HttpResponse object from an active QNetworkReply. */
51 static HttpResponse fromNetworkReply(QNetworkReply *reply);
52 /** Read from an HAR entry.
53 * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
54 */
55 Q_DECL_HIDDEN static HttpResponse fromHarEntry(const QJsonObject &harEntry);
56 /** Read a set of HTTP responses from an HAR file. */
57 Q_DECL_HIDDEN static QList<HttpResponse> fromHarFile(const QByteArray &harFile);
58
59private:
61};
62
63}
64
65Q_DECLARE_METATYPE(KItinerary::HttpResponse)
66
67#endif // KITINERARY_HTTPRESPONSE_H
Container for an HTTP response to be passed into the extractor engine.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.