Changeset 229032 in webkit


Ignore:
Timestamp:
Feb 26, 2018 12:02:40 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[Curl] Cookies are not being added to the Cookie field in Request Headers
https://bugs.webkit.org/show_bug.cgi?id=183095

Patch by Christopher Reid <chris.reid@sony.com> on 2018-02-26
Reviewed by Alex Christensen.

Populating the Cookie request header field now that cookies are no longer handled in libcurl.

  • platform/network/curl/CookieJarCurlDatabase.cpp: Renaming the httpOnly variable as its actual use wasn't clear
  • platform/network/curl/ResourceHandleCurl.cpp:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r229030 r229032  
     12018-02-26  Christopher Reid  <chris.reid@sony.com>
     2
     3        [Curl] Cookies are not being added to the Cookie field in Request Headers
     4        https://bugs.webkit.org/show_bug.cgi?id=183095
     5
     6        Reviewed by Alex Christensen.
     7
     8        Populating the Cookie request header field now that cookies are no longer handled in libcurl.
     9
     10        * platform/network/curl/CookieJarCurlDatabase.cpp: Renaming the httpOnly variable as its actual use wasn't clear
     11        * platform/network/curl/ResourceHandleCurl.cpp:
     12
    1132018-02-26  Antoine Quint  <graouts@apple.com>
    214
  • trunk/Source/WebCore/platform/network/curl/CookieJarCurlDatabase.cpp

    r228250 r229032  
    3939namespace WebCore {
    4040
    41 static String cookiesForSession(const NetworkStorageSession& session, const URL&, const URL& url, bool httponly)
     41static String cookiesForSession(const NetworkStorageSession& session, const URL&, const URL& url, bool forHTTPHeader)
    4242{
    4343    StringBuilder cookies;
    4444
    4545    CookieJarDB& cookieJarDB = session.cookieDatabase();
    46     auto isHttpOnly = (httponly ? std::nullopt : std::optional<bool> {false});
     46    auto searchHTTPOnly = (forHTTPHeader ? std::nullopt : std::optional<bool> {false});
    4747    auto secure = url.protocolIs("https") ? std::nullopt : std::optional<bool> {false};
    4848
    4949    Vector<Cookie> results;
    50     if (cookieJarDB.searchCookies(url.string(), isHttpOnly, secure, std::nullopt, results)) {
     50    if (cookieJarDB.searchCookies(url.string(), searchHTTPOnly, secure, std::nullopt, results)) {
    5151        for (auto result : results) {
    5252            if (!cookies.isEmpty())
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp

    r228577 r229032  
    3434
    3535#include "CookieJarCurl.h"
     36#include "CookiesStrategy.h"
    3637#include "CredentialStorage.h"
    3738#include "CurlCacheManager.h"
     
    4142#include "HTTPParsers.h"
    4243#include "Logging.h"
     44#include "NetworkStorageSession.h"
    4345#include "ResourceHandleInternal.h"
    4446#include "SharedBuffer.h"
     
    132134        }
    133135    }
     136
     137    auto& storageSession = NetworkStorageSession::defaultStorageSession();
     138    auto& cookieJar = storageSession.cookieStorage();
     139    auto includeSecureCookies = request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No;
     140    String cookieHeaderField = cookieJar.cookieRequestHeaderFieldValue(storageSession, request.firstPartyForCookies(), request.url(), std::nullopt, std::nullopt, includeSecureCookies).first;
     141    if (!cookieHeaderField.isEmpty())
     142        request.addHTTPHeaderField(HTTPHeaderName::Cookie, cookieHeaderField);
    134143
    135144    CurlRequest::ShouldSuspend shouldSuspend = d->m_defersLoading ? CurlRequest::ShouldSuspend::Yes : CurlRequest::ShouldSuspend::No;
Note: See TracChangeset for help on using the changeset viewer.