diff options
Diffstat (limited to 'src/core/net/url_request_custom_job_proxy.cpp')
-rw-r--r-- | src/core/net/url_request_custom_job_proxy.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp index 45372f020..54faddc62 100644 --- a/src/core/net/url_request_custom_job_proxy.cpp +++ b/src/core/net/url_request_custom_job_proxy.cpp @@ -6,6 +6,7 @@ #include "content/public/browser/browser_thread.h" #include "net/base/net_errors.h" +#include "services/network/public/cpp/resource_request_body.h" #include "api/qwebengineurlrequestjob.h" #include "profile_adapter.h" @@ -40,7 +41,8 @@ void URLRequestCustomJobProxy::release() } } -void URLRequestCustomJobProxy::reply(std::string contentType, QIODevice *device) +void URLRequestCustomJobProxy::reply(std::string contentType, QIODevice *device, + QMultiMap<QByteArray, QByteArray> additionalResponseHeaders) { if (!m_client) return; @@ -50,14 +52,15 @@ void URLRequestCustomJobProxy::reply(std::string contentType, QIODevice *device) if (sidx > 0) { const int cidx = qcontentType.indexOf("charset=", sidx); if (cidx > 0) { - m_client->m_charset = qcontentType.mid(cidx + 8).toStdString(); + m_client->m_charset = qcontentType.mid(cidx + 8).trimmed().toStdString(); qcontentType = qcontentType.first(sidx); } else { qWarning() << "QWebEngineUrlRequestJob::reply(): Unrecognized content-type format with ';'" << qcontentType; } } - m_client->m_mimeType = qcontentType.toStdString(); + m_client->m_mimeType = qcontentType.trimmed().toStdString(); m_client->m_device = device; + m_client->m_additionalResponseHeaders = std::move(additionalResponseHeaders); if (m_client->m_device && !m_client->m_device->isReadable()) m_client->m_device->open(QIODevice::ReadOnly); @@ -115,6 +118,11 @@ void URLRequestCustomJobProxy::fail(int error) // else we fail on the next read, or the read that might already be in progress } +void URLRequestCustomJobProxy::succeed() +{ + m_client->notifySuccess(); +} + void URLRequestCustomJobProxy::readyRead() { DCHECK (m_ioTaskRunner->RunsTasksInCurrentSequence()); @@ -124,7 +132,8 @@ void URLRequestCustomJobProxy::readyRead() void URLRequestCustomJobProxy::initialize(GURL url, std::string method, absl::optional<url::Origin> initiator, - std::map<std::string, std::string> headers) + std::map<std::string, std::string> headers, + scoped_refptr<network::ResourceRequestBody> requestBody) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); Q_ASSERT(!m_delegate); @@ -142,10 +151,9 @@ void URLRequestCustomJobProxy::initialize(GURL url, std::string method, qHeaders.insert(toQByteArray(it->first), toQByteArray(it->second)); if (schemeHandler) { - m_delegate = new URLRequestCustomJobDelegate(this, toQt(url), - QByteArray::fromStdString(method), - initiatorOrigin, - qHeaders); + m_delegate = + new URLRequestCustomJobDelegate(this, toQt(url), QByteArray::fromStdString(method), + initiatorOrigin, qHeaders, requestBody.get()); QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(m_delegate); schemeHandler->requestStarted(requestJob); } |