summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/net/url_request_custom_job_proxy.cpp17
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())