Falkon Develop
Cross-platform Qt-based web browser
loadrequest.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2014-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "loadrequest.h"
19
21 : m_operation(GetOperation)
22{
23}
24
26
27= default;
28
29LoadRequest::LoadRequest(const QUrl &url, LoadRequest::Operation op, const QByteArray &data)
30 : m_url(url)
31 , m_operation(op)
32 , m_data(data)
33{
34}
35
37= default;
38
40{
41 return m_url.isValid();
42}
43
44QUrl LoadRequest::url() const
45{
46 return m_url;
47}
48
49void LoadRequest::setUrl(const QUrl &url)
50{
51 m_url = url;
52}
53
55{
56 return QUrl::fromPercentEncoding(m_url.toEncoded());
57}
58
60{
61 return m_operation;
62}
63
65{
66 m_operation = op;
67}
68
69QByteArray LoadRequest::data() const
70{
71 return m_data;
72}
73
74void LoadRequest::setData(const QByteArray &data)
75{
76 m_data = data;
77}
78
79QWebEngineHttpRequest LoadRequest::webRequest() const
80{
81 QWebEngineHttpRequest req(m_url, m_operation == GetOperation ? QWebEngineHttpRequest::Get : QWebEngineHttpRequest::Post);
82 req.setPostData(m_data);
83 return req;
84}
Operation operation() const
Definition: loadrequest.cpp:59
QUrl url() const
Definition: loadrequest.cpp:44
QByteArray data() const
Definition: loadrequest.cpp:69
void setOperation(Operation op)
Definition: loadrequest.cpp:64
bool isValid() const
Definition: loadrequest.cpp:39
QString urlString() const
Definition: loadrequest.cpp:54
void setUrl(const QUrl &url)
Definition: loadrequest.cpp:49
LoadRequest & operator=(const LoadRequest &other)
QWebEngineHttpRequest webRequest() const
Definition: loadrequest.cpp:79
void setData(const QByteArray &data)
Definition: loadrequest.cpp:74