diff options
author | Kaloyan Chehlarski <[email protected]> | 2025-02-28 13:11:33 +0100 |
---|---|---|
committer | Kaloyan Chehlarski <[email protected]> | 2025-05-22 20:05:48 +0200 |
commit | 852efca0d0a7a98f2c49063ed49e6dec14176391 (patch) | |
tree | 9d9d2829ecd93aff33ba9e52d21e8a091874d3ab | |
parent | ccb741ff3f5214c854141e97a07f62bfa86e82b1 (diff) |
We don't need to be parsing Content-Type headers ourselves, and the
existing code won't parse the charset correctly in all cases. Instead,
the parsing is now done through net::HttpUtil::ParseContentType().
Pick-to: 6.9 6.8
Change-Id: I94054a8fc1aa3a2b9f8c504e194530719ccdcc11
Reviewed-by: Anu Aliyas <[email protected]>
-rw-r--r-- | src/core/net/url_request_custom_job_proxy.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp index 4ec282f42..bf1a297ab 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 "net/http/http_util.h" #include "services/network/public/cpp/resource_request_body.h" #include "api/qwebengineurlrequestjob.h" @@ -47,20 +48,8 @@ void URLRequestCustomJobProxy::reply(std::string contentType, QIODevice *device, if (!m_client) return; DCHECK (!m_ioTaskRunner || m_ioTaskRunner->RunsTasksInCurrentSequence()); - QByteArray qcontentType = QByteArray::fromStdString(contentType).toLower(); - const int sidx = qcontentType.indexOf(';'); - if (sidx > 0) { - const int cidx = qcontentType.indexOf("charset=", sidx); - if (cidx > 0) { - m_client->m_charset = qcontentType.mid(cidx + 8).trimmed().toStdString(); - qcontentType = qcontentType.first(sidx); - } else { - qWarning("QWebEngineUrlRequestJob::reply(): Unrecognized content-type format with ';' " - "%s", - qcontentType.constData()); - } - } - m_client->m_mimeType = qcontentType.trimmed().toStdString(); + bool hadCharset = false; + net::HttpUtil::ParseContentType(contentType, &m_client->m_mimeType, &m_client->m_charset, &hadCharset, nullptr); m_client->m_device = device; m_client->m_additionalResponseHeaders = std::move(additionalResponseHeaders); if (m_client->m_device && !m_client->m_device->isReadable()) |