summaryrefslogtreecommitdiffstats
path: root/src/core/net/url_request_custom_job_delegate.h
blob: 63db464643391f504e9d61fc4dcbfb5c353af0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#ifndef URL_REQUEST_CUSTOM_JOB_DELEGATE_H_
#define URL_REQUEST_CUSTOM_JOB_DELEGATE_H_

#include "base/memory/ref_counted.h"
#include "qtwebenginecoreglobal_p.h"
#include "resource_request_body_qt.h"

#include <QMap>
#include <QObject>
#include <QUrl>

QT_FORWARD_DECLARE_CLASS(QIODevice)

namespace network {
class ResourceRequestBody;
}

namespace QtWebEngineCore {

class URLRequestCustomJobProxy;

class Q_WEBENGINECORE_EXPORT URLRequestCustomJobDelegate : public QObject
{
    Q_OBJECT
public:
    ~URLRequestCustomJobDelegate();

    enum Error {
        NoError = 0,
        UrlNotFound,
        UrlInvalid,
        RequestAborted,
        RequestDenied,
        RequestFailed
    };

    QUrl url() const;
    QByteArray method() const;
    QUrl initiator() const;
    QMap<QByteArray, QByteArray> requestHeaders() const;
    QIODevice *requestBody();

    void
    setAdditionalResponseHeaders(const QMultiMap<QByteArray, QByteArray> &additionalResponseHeaders);
    void reply(const QByteArray &contentType, QIODevice *device);
    void redirect(const QUrl &url);
    void abort();
    void fail(Error);

private Q_SLOTS:
    void slotReadyRead();

private:
    URLRequestCustomJobDelegate(URLRequestCustomJobProxy *proxy, const QUrl &url,
                                const QByteArray &method, const QUrl &initiatorOrigin,
                                const QMap<QByteArray, QByteArray> &requestHeaders,
                                network::ResourceRequestBody *requestBody);

    friend class URLRequestCustomJobProxy;
    scoped_refptr<URLRequestCustomJobProxy> m_proxy;
    QUrl m_request;
    QByteArray m_method;
    QUrl m_initiatorOrigin;
    const QMap<QByteArray, QByteArray> m_requestHeaders;
    QMultiMap<QByteArray, QByteArray> m_additionalResponseHeaders;
    ResourceRequestBody m_resourceRequestBody;
};

} // namespace

#endif // URL_REQUEST_CUSTOM_JOB_DELEGATE_H_