Changeset 273905 in webkit


Ignore:
Timestamp:
Mar 4, 2021 11:30:12 AM (17 months ago)
Author:
youenn@apple.com
Message:

In case of POST navigation redirected by a 302, the 'Origin' header is kept in the redirected request
https://bugs.webkit.org/show_bug.cgi?id=222653
<rdar://problem/74983521>

Reviewed by Alex Christensen.

Source/WebCore:

Remove Origin header if the navigation request goes from POST to GET.
This aligns with other browsers and removes some known interop issues.
This is consistent with WebKit not sending Origin headers for GET navigations.

Test: http/wpt/fetch/navigation-post-to-get-origin.html

  • loader/DocumentLoader.cpp:

(WebCore::isRedirectToGetAfterPost):
(WebCore::DocumentLoader::willSendRequest):

LayoutTests:

  • http/wpt/fetch/echo-origin.py: Added.
  • http/wpt/fetch/navigation-post-to-get-origin-expected.txt: Added.
  • http/wpt/fetch/navigation-post-to-get-origin.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273902 r273905  
     12021-03-04  Youenn Fablet  <youenn@apple.com>
     2
     3        In case of POST navigation redirected by a 302, the 'Origin' header is kept in the redirected request
     4        https://bugs.webkit.org/show_bug.cgi?id=222653
     5        <rdar://problem/74983521>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/wpt/fetch/echo-origin.py: Added.
     10        * http/wpt/fetch/navigation-post-to-get-origin-expected.txt: Added.
     11        * http/wpt/fetch/navigation-post-to-get-origin.html: Added.
     12
    1132021-03-04  Said Abou-Hallawa  <said@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r273903 r273905  
     12021-03-04  Youenn Fablet  <youenn@apple.com>
     2
     3        In case of POST navigation redirected by a 302, the 'Origin' header is kept in the redirected request
     4        https://bugs.webkit.org/show_bug.cgi?id=222653
     5        <rdar://problem/74983521>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Remove Origin header if the navigation request goes from POST to GET.
     10        This aligns with other browsers and removes some known interop issues.
     11        This is consistent with WebKit not sending Origin headers for GET navigations.
     12
     13        Test: http/wpt/fetch/navigation-post-to-get-origin.html
     14
     15        * loader/DocumentLoader.cpp:
     16        (WebCore::isRedirectToGetAfterPost):
     17        (WebCore::DocumentLoader::willSendRequest):
     18
    1192021-03-04  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r273183 r273905  
    496496}
    497497
     498static bool isRedirectToGetAfterPost(const ResourceRequest& oldRequest, const ResourceRequest& newRequest)
     499{
     500    return oldRequest.httpMethod() == "POST" && newRequest.httpMethod() == "GET";
     501}
     502
    498503bool DocumentLoader::isPostOrRedirectAfterPost(const ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
    499504{
     
    660665    if (newRequest.cachePolicy() == ResourceRequestCachePolicy::UseProtocolCachePolicy && isPostOrRedirectAfterPost(newRequest, redirectResponse))
    661666        newRequest.setCachePolicy(ResourceRequestCachePolicy::ReloadIgnoringCacheData);
     667
     668    if (isRedirectToGetAfterPost(m_request, newRequest))
     669        newRequest.clearHTTPOrigin();
    662670
    663671    if (&topFrame != m_frame) {
Note: See TracChangeset for help on using the changeset viewer.