File indexing completed on 2024-05-12 04:58:29
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2014-2018 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "loadrequest.h" 0019 0020 LoadRequest::LoadRequest() 0021 : m_operation(GetOperation) 0022 { 0023 } 0024 0025 LoadRequest::LoadRequest(const LoadRequest &other) 0026 0027 = default; 0028 0029 LoadRequest::LoadRequest(const QUrl &url, LoadRequest::Operation op, const QByteArray &data) 0030 : m_url(url) 0031 , m_operation(op) 0032 , m_data(data) 0033 { 0034 } 0035 0036 LoadRequest &LoadRequest::operator=(const LoadRequest &other) 0037 = default; 0038 0039 bool LoadRequest::isValid() const 0040 { 0041 return m_url.isValid(); 0042 } 0043 0044 QUrl LoadRequest::url() const 0045 { 0046 return m_url; 0047 } 0048 0049 void LoadRequest::setUrl(const QUrl &url) 0050 { 0051 m_url = url; 0052 } 0053 0054 QString LoadRequest::urlString() const 0055 { 0056 return QUrl::fromPercentEncoding(m_url.toEncoded()); 0057 } 0058 0059 LoadRequest::Operation LoadRequest::operation() const 0060 { 0061 return m_operation; 0062 } 0063 0064 void LoadRequest::setOperation(LoadRequest::Operation op) 0065 { 0066 m_operation = op; 0067 } 0068 0069 QByteArray LoadRequest::data() const 0070 { 0071 return m_data; 0072 } 0073 0074 void LoadRequest::setData(const QByteArray &data) 0075 { 0076 m_data = data; 0077 } 0078 0079 QWebEngineHttpRequest LoadRequest::webRequest() const 0080 { 0081 QWebEngineHttpRequest req(m_url, m_operation == GetOperation ? QWebEngineHttpRequest::Get : QWebEngineHttpRequest::Post); 0082 req.setPostData(m_data); 0083 return req; 0084 }