Skip to content

Commit

Permalink
[SOUP] Do not handle HSTS upgrade as a redirection in case of redirec…
Browse files Browse the repository at this point in the history
…tion

https://bugs.webkit.org/show_bug.cgi?id=255218

Reviewed by Adrian Perez de Castro.

We handle HSTS upgrades as a redirection to let Web and UI processes
know about the URL change, but in case of redirection, the new request
is originated in the network process, so we can just update the URL.

* Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::protocolUpgradedViaHSTS):

Canonical link: https://commits.webkit.org/262817@main
  • Loading branch information
carlosgcampos committed Apr 11, 2023
1 parent 8967198 commit cebc106
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
Expand Up @@ -1620,8 +1620,14 @@ bool NetworkDataTaskSoup::shouldAllowHSTSProtocolUpgrade() const

void NetworkDataTaskSoup::protocolUpgradedViaHSTS(SoupMessage* soupMessage)
{
m_response = ResourceResponse::syntheticRedirectResponse(m_currentRequest.url(), soupURIToURL(soup_message_get_uri(soupMessage)));
continueHTTPRedirection();
if (!m_response.isNull() && !m_response.httpHeaderField(HTTPHeaderName::Location).isEmpty()) {
// We handle HSTS upgrades as a redirection to let Web and UI processes know about the URL change, but in
// case of redirection, the new request is originated in the network process, so we can just update the URL.
m_currentRequest.setURL(soupURIToURL(soup_message_get_uri(m_soupMessage.get())));
} else {
m_response = ResourceResponse::syntheticRedirectResponse(m_currentRequest.url(), soupURIToURL(soup_message_get_uri(soupMessage)));
continueHTTPRedirection();
}
}

#if USE(SOUP2)
Expand Down

0 comments on commit cebc106

Please sign in to comment.