Changeset 254345 in webkit


Ignore:
Timestamp:
Jan 10, 2020 10:06:08 AM (4 years ago)
Author:
achristensen@apple.com
Message:

Expand _WKResourceLoadDelegate callbacks
https://bugs.webkit.org/show_bug.cgi?id=206037
Source/WebKit:

<rdar://problem/57132290>

Reviewed by Youenn Fablet.

Add 5 informative delegate callbacks at these times during the loading process:

  1. When a request is sent.
  2. When a redirect happens.
  3. When a challenge happens.
  4. When a response is received.
  5. When loading completes or fails.

As mentioned in r254183 these callbacks are only called when a _WKResourceLoadDelegate is given to a WKWebView.
We add a new struct ResourceLoadInfo which will need to be expanded containing currently only the load identifier.
Covered by new API tests which verify the validity of the sent information.

  • NetworkProcess/NetworkLoad.cpp:

(WebKit::NetworkLoad::didReceiveChallenge):

  • NetworkProcess/NetworkLoadClient.h:

(WebKit::NetworkLoadClient::didReceiveChallenge):

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::generateResourceLoadID):
(WebKit::NetworkResourceLoader::startNetworkLoad):
(WebKit::NetworkResourceLoader::resourceLoadInfo):
(WebKit::NetworkResourceLoader::didReceiveResponse):
(WebKit::NetworkResourceLoader::didFinishLoading):
(WebKit::NetworkResourceLoader::didFailLoading):
(WebKit::NetworkResourceLoader::didReceiveChallenge):
Add a way to send a message informing that a challenge happened with information gathered from the NetworkResourceLoader,
which previously was not informed of challenges because the challenges went directly from the NetworkLoad to the AuthenticationManager.
(WebKit::NetworkResourceLoader::willSendRedirectedRequest):
(WebKit::NetworkResourceLoader::continueWillSendRequest):
(WebKit::m_shouldCaptureExtraNetworkLoadMetrics): Deleted.

  • NetworkProcess/NetworkResourceLoader.h:
  • Shared/API/APIObject.h:
  • Shared/Cocoa/APIObject.mm:

(API::Object::newObject):

  • Shared/ResourceLoadInfo.h: Added.

(WebKit::ResourceLoadInfo::encode const):
(WebKit::ResourceLoadInfo::decode):

  • SourcesCocoa.txt:
  • UIProcess/API/APIResourceLoadClient.h:
  • UIProcess/API/APIResourceLoadInfo.h: Added.
  • UIProcess/API/Cocoa/_WKResourceLoadDelegate.h:
  • UIProcess/API/Cocoa/_WKResourceLoadInfo.h: Added.
  • UIProcess/API/Cocoa/_WKResourceLoadInfo.mm: Added.

(-[_WKResourceLoadInfo dealloc]):
(-[_WKResourceLoadInfo resourceLoadID]):
(-[_WKResourceLoadInfo _apiObject]):

  • UIProcess/API/Cocoa/_WKResourceLoadInfoInternal.h: Added.
  • UIProcess/Authentication/AuthenticationChallengeProxy.cpp:

(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
An AuthenticationChallengeProxy was only used for challenges that needed credentials, so they wrapped a CompletionHandler.
This new type of informative-only challenge will be given a null CompletionHandler, which means no action can be taken.

  • UIProcess/Cocoa/ResourceLoadDelegate.h:
  • UIProcess/Cocoa/ResourceLoadDelegate.mm:

(WebKit::ResourceLoadDelegate::setDelegate):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::didSendRequest const):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::didPerformHTTPRedirection const):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::didReceiveChallenge const):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::didReceiveResponse const):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::didCompleteWithError const):
(WebKit::ResourceLoadDelegate::ResourceLoadClient::willSendRequest const): Deleted.

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::resourceLoadDidSendRequest):
(WebKit::NetworkProcessProxy::resourceLoadDidPerformHTTPRedirection):
(WebKit::NetworkProcessProxy::resourceLoadDidReceiveChallenge):
(WebKit::NetworkProcessProxy::resourceLoadDidReceiveResponse):
(WebKit::NetworkProcessProxy::resourceLoadDidCompleteWithError):
(WebKit::NetworkProcessProxy::pageWillSendRequest): Deleted.

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/Network/NetworkProcessProxy.messages.in:
  • UIProcess/WebPageProxy.cpp:
  • UIProcess/WebPageProxy.h:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):

  • WebProcess/Network/WebResourceLoader.cpp:

(WebKit::WebResourceLoader::willSendRequest):

Tools:

Reviewed by Youenn Fablet.

  • TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:

(-[TestResourceLoadDelegate webView:resourceLoad:didSendRequest:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didPerformHTTPRedirection:newRequest:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveChallenge:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveResponse:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didCompleteWithError:]):
(TEST):
(-[TestResourceLoadDelegate webView:willSendRequest:]): Deleted.

  • TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
  • TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:

(TEST):

  • TestWebKitAPI/cocoa/HTTPServer.h:

(TestWebKitAPI::HTTPServer::HTTPResponse::HTTPResponse):
Add the ability to have non-200 status codes in responses.
Also switch the order of parameters to reflect the fact that header fields are sent before the body.

  • TestWebKitAPI/cocoa/HTTPServer.mm:

(TestWebKitAPI::statusText):
(TestWebKitAPI::HTTPServer::respondToRequests):

Location:
trunk
Files:
6 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r254344 r254345  
     12020-01-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        Expand _WKResourceLoadDelegate callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=206037
     5        <rdar://problem/57132290>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Add 5 informative delegate callbacks at these times during the loading process:
     10        1. When a request is sent.
     11        2. When a redirect happens.
     12        3. When a challenge happens.
     13        4. When a response is received.
     14        5. When loading completes or fails.
     15
     16        As mentioned in r254183 these callbacks are only called when a _WKResourceLoadDelegate is given to a WKWebView.
     17        We add a new struct ResourceLoadInfo which will need to be expanded containing currently only the load identifier.
     18        Covered by new API tests which verify the validity of the sent information.
     19
     20        * NetworkProcess/NetworkLoad.cpp:
     21        (WebKit::NetworkLoad::didReceiveChallenge):
     22        * NetworkProcess/NetworkLoadClient.h:
     23        (WebKit::NetworkLoadClient::didReceiveChallenge):
     24        * NetworkProcess/NetworkResourceLoader.cpp:
     25        (WebKit::generateResourceLoadID):
     26        (WebKit::NetworkResourceLoader::startNetworkLoad):
     27        (WebKit::NetworkResourceLoader::resourceLoadInfo):
     28        (WebKit::NetworkResourceLoader::didReceiveResponse):
     29        (WebKit::NetworkResourceLoader::didFinishLoading):
     30        (WebKit::NetworkResourceLoader::didFailLoading):
     31        (WebKit::NetworkResourceLoader::didReceiveChallenge):
     32        Add a way to send a message informing that a challenge happened with information gathered from the NetworkResourceLoader,
     33        which previously was not informed of challenges because the challenges went directly from the NetworkLoad to the AuthenticationManager.
     34        (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
     35        (WebKit::NetworkResourceLoader::continueWillSendRequest):
     36        (WebKit::m_shouldCaptureExtraNetworkLoadMetrics): Deleted.
     37        * NetworkProcess/NetworkResourceLoader.h:
     38        * Shared/API/APIObject.h:
     39        * Shared/Cocoa/APIObject.mm:
     40        (API::Object::newObject):
     41        * Shared/ResourceLoadInfo.h: Added.
     42        (WebKit::ResourceLoadInfo::encode const):
     43        (WebKit::ResourceLoadInfo::decode):
     44        * SourcesCocoa.txt:
     45        * UIProcess/API/APIResourceLoadClient.h:
     46        * UIProcess/API/APIResourceLoadInfo.h: Added.
     47        * UIProcess/API/Cocoa/_WKResourceLoadDelegate.h:
     48        * UIProcess/API/Cocoa/_WKResourceLoadInfo.h: Added.
     49        * UIProcess/API/Cocoa/_WKResourceLoadInfo.mm: Added.
     50        (-[_WKResourceLoadInfo dealloc]):
     51        (-[_WKResourceLoadInfo resourceLoadID]):
     52        (-[_WKResourceLoadInfo _apiObject]):
     53        * UIProcess/API/Cocoa/_WKResourceLoadInfoInternal.h: Added.
     54        * UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
     55        (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
     56        An AuthenticationChallengeProxy was only used for challenges that needed credentials, so they wrapped a CompletionHandler.
     57        This new type of informative-only challenge will be given a null CompletionHandler, which means no action can be taken.
     58        * UIProcess/Cocoa/ResourceLoadDelegate.h:
     59        * UIProcess/Cocoa/ResourceLoadDelegate.mm:
     60        (WebKit::ResourceLoadDelegate::setDelegate):
     61        (WebKit::ResourceLoadDelegate::ResourceLoadClient::didSendRequest const):
     62        (WebKit::ResourceLoadDelegate::ResourceLoadClient::didPerformHTTPRedirection const):
     63        (WebKit::ResourceLoadDelegate::ResourceLoadClient::didReceiveChallenge const):
     64        (WebKit::ResourceLoadDelegate::ResourceLoadClient::didReceiveResponse const):
     65        (WebKit::ResourceLoadDelegate::ResourceLoadClient::didCompleteWithError const):
     66        (WebKit::ResourceLoadDelegate::ResourceLoadClient::willSendRequest const): Deleted.
     67        * UIProcess/Network/NetworkProcessProxy.cpp:
     68        (WebKit::NetworkProcessProxy::resourceLoadDidSendRequest):
     69        (WebKit::NetworkProcessProxy::resourceLoadDidPerformHTTPRedirection):
     70        (WebKit::NetworkProcessProxy::resourceLoadDidReceiveChallenge):
     71        (WebKit::NetworkProcessProxy::resourceLoadDidReceiveResponse):
     72        (WebKit::NetworkProcessProxy::resourceLoadDidCompleteWithError):
     73        (WebKit::NetworkProcessProxy::pageWillSendRequest): Deleted.
     74        * UIProcess/Network/NetworkProcessProxy.h:
     75        * UIProcess/Network/NetworkProcessProxy.messages.in:
     76        * UIProcess/WebPageProxy.cpp:
     77        * UIProcess/WebPageProxy.h:
     78        * WebKit.xcodeproj/project.pbxproj:
     79        * WebProcess/Network/WebLoaderStrategy.cpp:
     80        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
     81        (WebKit::WebLoaderStrategy::startPingLoad):
     82        * WebProcess/Network/WebResourceLoader.cpp:
     83        (WebKit::WebResourceLoader::willSendRequest):
     84
    1852020-01-10  Alex Christensen  <achristensen@webkit.org>
    286
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp

    r249501 r254345  
    190190void NetworkLoad::didReceiveChallenge(AuthenticationChallenge&& challenge, ChallengeCompletionHandler&& completionHandler)
    191191{
     192    m_client.get().didReceiveChallenge(challenge);
     193
    192194    auto scheme = challenge.protectionSpace().authenticationScheme();
    193195    bool isTLSHandshake = scheme == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadClient.h

    r239007 r254345  
    3131
    3232namespace WebCore {
     33class AuthenticationChallenge;
    3334class NetworkLoadMetrics;
    3435class SharedBuffer;
     
    5556    virtual void didFailLoading(const WebCore::ResourceError&) = 0;
    5657    virtual void didBlockAuthenticationChallenge() { };
     58    virtual void didReceiveChallenge(const WebCore::AuthenticationChallenge&) { };
    5759    virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; }
    5860};
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r254183 r254345  
    4040#include "NetworkProcessProxyMessages.h"
    4141#include "NetworkSession.h"
     42#include "ResourceLoadInfo.h"
    4243#include "ServiceWorkerFetchTask.h"
    4344#include "SharedBufferDataReference.h"
     
    105106    , m_bufferingTimer { *this, &NetworkResourceLoader::bufferingTimerFired }
    106107    , m_shouldCaptureExtraNetworkLoadMetrics(m_connection->captureExtraNetworkLoadMetricsEnabled())
     108    , m_resourceLoadID { NetworkResourceLoadIdentifier::generate() }
    107109{
    108110    ASSERT(RunLoop::isMain());
     
    324326
    325327    if (m_parameters.pageHasResourceLoadClient)
    326         m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::PageWillSendRequest(m_parameters.webPageProxyID, request), 0);
     328        m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidSendRequest(m_parameters.webPageProxyID, resourceLoadInfo(), request), 0);
    327329
    328330    parameters.request = WTFMove(request);
     
    330332
    331333    RELEASE_LOG_IF_ALLOWED("startNetworkLoad: Going to the network (description=%{public}s)", m_networkLoad->description().utf8().data());
     334}
     335
     336ResourceLoadInfo NetworkResourceLoader::resourceLoadInfo()
     337{
     338    return {
     339        m_resourceLoadID
     340    };
    332341}
    333342
     
    548557    send(Messages::WebResourceLoader::DidReceiveResponse { response, willWaitForContinueDidReceiveResponse });
    549558
     559    if (m_parameters.pageHasResourceLoadClient)
     560        m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidReceiveResponse(m_parameters.webPageProxyID, resourceLoadInfo(), response), 0);
     561
    550562    if (willWaitForContinueDidReceiveResponse) {
    551563        m_responseCompletionHandler = WTFMove(completionHandler);
     
    623635
    624636    tryStoreAsCacheEntry();
     637
     638    if (m_parameters.pageHasResourceLoadClient)
     639        m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidCompleteWithError(m_parameters.webPageProxyID, resourceLoadInfo(), { }), 0);
    625640
    626641    cleanup(LoadResult::Success);
     
    656671    }
    657672
     673    if (m_parameters.pageHasResourceLoadClient)
     674        m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidCompleteWithError(m_parameters.webPageProxyID, resourceLoadInfo(), error), 0);
     675
    658676    cleanup(LoadResult::Failure);
    659677}
     
    663681    RELEASE_LOG_IF_ALLOWED("didBlockAuthenticationChallenge:");
    664682    send(Messages::WebResourceLoader::DidBlockAuthenticationChallenge());
     683}
     684
     685void NetworkResourceLoader::didReceiveChallenge(const AuthenticationChallenge& challenge)
     686{
     687    if (m_parameters.pageHasResourceLoadClient)
     688        m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidReceiveChallenge(m_parameters.webPageProxyID, resourceLoadInfo(), challenge), 0);
    665689}
    666690
     
    691715    RELEASE_LOG_IF_ALLOWED("willSendRedirectedRequest:");
    692716    ++m_redirectCount;
     717    m_redirectResponse = redirectResponse;
    693718
    694719    Optional<AdClickAttribution::Conversion> adClickConversion;
     
    866891    if (m_networkLoad) {
    867892        RELEASE_LOG_IF_ALLOWED("continueWillSendRequest: Telling NetworkLoad to proceed with the redirect");
     893
     894        if (m_parameters.pageHasResourceLoadClient && !newRequest.isNull())
     895            m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidPerformHTTPRedirection(m_parameters.webPageProxyID, resourceLoadInfo(), m_redirectResponse, newRequest), 0);
     896
    868897        m_networkLoad->continueWillSendRequest(WTFMove(newRequest));
    869898    }
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h

    r253528 r254345  
    3232#include "NetworkConnectionToWebProcessMessagesReplies.h"
    3333#include "NetworkLoadClient.h"
     34#include "NetworkResourceLoadIdentifier.h"
    3435#include "NetworkResourceLoadParameters.h"
    3536#include <WebCore/AdClickAttribution.h>
     
    5455class ServiceWorkerFetchTask;
    5556class WebSWServerConnection;
     57
     58struct ResourceLoadInfo;
    5659
    5760namespace NetworkCache {
     
    98101
    99102    // NetworkLoadClient.
    100     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
    101     bool isSynchronous() const override;
    102     bool isAllowedToAskUserForCredentials() const override { return m_isAllowedToAskUserForCredentials; }
    103     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&&) override;
    104     void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) override;
    105     void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) override;
    106     void didFinishLoading(const WebCore::NetworkLoadMetrics&) override;
    107     void didFailLoading(const WebCore::ResourceError&) override;
    108     void didBlockAuthenticationChallenge() override;
    109     bool shouldCaptureExtraNetworkLoadMetrics() const override;
     103    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final;
     104    bool isSynchronous() const final;
     105    bool isAllowedToAskUserForCredentials() const final { return m_isAllowedToAskUserForCredentials; }
     106    void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&&) final;
     107    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
     108    void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) final;
     109    void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
     110    void didFailLoading(const WebCore::ResourceError&) final;
     111    void didBlockAuthenticationChallenge() final;
     112    void didReceiveChallenge(const WebCore::AuthenticationChallenge&) final;
     113    bool shouldCaptureExtraNetworkLoadMetrics() const final;
    110114
    111115    void convertToDownload(DownloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
     
    195199
    196200    Optional<Seconds> validateCacheEntryForMaxAgeCapValidation(const WebCore::ResourceRequest&, const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse&);
     201
     202    ResourceLoadInfo resourceLoadInfo();
    197203
    198204    const NetworkResourceLoadParameters m_parameters;
     
    235241    std::unique_ptr<ServiceWorkerFetchTask> m_serviceWorkerFetchTask;
    236242#endif
     243    NetworkResourceLoadIdentifier m_resourceLoadID;
     244    WebCore::ResourceResponse m_redirectResponse;
    237245};
    238246
  • trunk/Source/WebKit/Shared/API/APIObject.h

    r253868 r254345  
    7272        RenderLayer,
    7373        RenderObject,
     74        ResourceLoadInfo,
    7475        SecurityOrigin,
    7576        SessionState,
  • trunk/Source/WebKit/Shared/Cocoa/APIObject.mm

    r253868 r254345  
    8282#import "_WKInternalDebugFeatureInternal.h"
    8383#import "_WKProcessPoolConfigurationInternal.h"
     84#import "_WKResourceLoadInfoInternal.h"
    8485#import "_WKResourceLoadStatisticsFirstPartyInternal.h"
    8586#import "_WKResourceLoadStatisticsThirdPartyInternal.h"
     
    333334        break;
    334335
     336    case Type::ResourceLoadInfo:
     337        wrapper = [_WKResourceLoadInfo alloc];
     338        break;
     339           
    335340    case Type::ResourceLoadStatisticsFirstParty:
    336341        wrapper = [_WKResourceLoadStatisticsFirstParty alloc];
  • trunk/Source/WebKit/SourcesCocoa.txt

    r254194 r254345  
    265265UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
    266266UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
     267UIProcess/API/Cocoa/_WKResourceLoadInfo.mm
    267268UIProcess/API/Cocoa/_WKSessionState.mm
    268269UIProcess/API/Cocoa/_WKTextInputContext.mm
  • trunk/Source/WebKit/UIProcess/API/APIResourceLoadClient.h

    r254183 r254345  
    2626#pragma once
    2727
     28namespace WebKit {
     29class AuthenticationChallengeProxy;
     30struct ResourceLoadInfo;
     31}
     32
    2833namespace API {
    2934
     
    3237    virtual ~ResourceLoadClient() = default;
    3338
    34     virtual void willSendRequest(const WebCore::ResourceRequest&) const = 0;
     39    virtual void didSendRequest(WebKit::ResourceLoadInfo&&, WebCore::ResourceRequest&&) const = 0;
     40    virtual void didPerformHTTPRedirection(WebKit::ResourceLoadInfo&&, WebCore::ResourceResponse&&, WebCore::ResourceRequest&&) const = 0;
     41    virtual void didReceiveChallenge(WebKit::ResourceLoadInfo&&, WebKit::AuthenticationChallengeProxy&) const = 0;
     42    virtual void didReceiveResponse(WebKit::ResourceLoadInfo&&, WebCore::ResourceResponse&&) const = 0;
     43    virtual void didCompleteWithError(WebKit::ResourceLoadInfo&&, WebCore::ResourceError&&) const = 0;
    3544};
    3645
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadDelegate.h

    r254183 r254345  
    2626#import <WebKit/WKFoundation.h>
    2727
     28@class _WKResourceLoadInfo;
     29
    2830NS_ASSUME_NONNULL_BEGIN
    2931
     
    3234@optional
    3335
    34 - (void)webView:(WKWebView *)webView willSendRequest:(NSURLRequest *)request;
     36- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didSendRequest:(NSURLRequest *)request;
     37- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didPerformHTTPRedirection:(NSURLResponse *)response newRequest:(NSURLRequest *)request;
     38- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge;
     39- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveResponse:(NSURLResponse *)response;
     40- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didCompleteWithError:(NSError * __nullable)error;
    3541
    3642@end
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp

    r241658 r254345  
    4646AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, Ref<IPC::Connection>&& connection, WeakPtr<SecKeyProxyStore>&& secKeyProxyStore)
    4747    : m_coreAuthenticationChallenge(WTFMove(authenticationChallenge))
    48     , m_listener(AuthenticationDecisionListener::create([challengeID, connection = WTFMove(connection), secKeyProxyStore = WTFMove(secKeyProxyStore)](AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential) {
     48    , m_listener(AuthenticationDecisionListener::create(challengeID ? CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>([challengeID, connection = WTFMove(connection), secKeyProxyStore = WTFMove(secKeyProxyStore)](AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential) {
    4949#if HAVE(SEC_KEY_PROXY)
    5050        if (secKeyProxyStore && secKeyProxyStore->initialize(credential)) {
     
    5454#endif
    5555        connection->send(Messages::AuthenticationManager::CompleteAuthenticationChallenge(challengeID, disposition, credential), 0);
    56     }))
     56    }) : nullptr))
    5757{
    5858}
  • trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadDelegate.h

    r254183 r254345  
    5858    private:
    5959        // API::ResourceLoadClient
    60         void willSendRequest(const WebCore::ResourceRequest&) const final;
     60        void didSendRequest(ResourceLoadInfo&&, WebCore::ResourceRequest&&) const final;
     61        void didPerformHTTPRedirection(ResourceLoadInfo&&, WebCore::ResourceResponse&&, WebCore::ResourceRequest&&) const final;
     62        void didReceiveChallenge(ResourceLoadInfo&&, WebKit::AuthenticationChallengeProxy&) const final;
     63        void didReceiveResponse(ResourceLoadInfo&&, WebCore::ResourceResponse&&) const final;
     64        void didCompleteWithError(ResourceLoadInfo&&, WebCore::ResourceError&&) const final;
    6165
    6266        ResourceLoadDelegate& m_resourceLoadDelegate;
     
    6771
    6872    struct {
    69         bool willSendRequest : 1;
     73        bool didSendRequest : 1;
     74        bool didPerformHTTPRedirection : 1;
     75        bool didReceiveChallenge : 1;
     76        bool didReceiveResponse : 1;
     77        bool didCompleteWithError : 1;
    7078    } m_delegateMethods;
    7179};
  • trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadDelegate.mm

    r254183 r254345  
    2828
    2929#import "_WKResourceLoadDelegate.h"
     30#import "_WKResourceLoadInfoInternal.h"
    3031
    3132namespace WebKit {
     
    5253    m_delegate = delegate;
    5354
    54     m_delegateMethods.willSendRequest = [delegate respondsToSelector:@selector(webView:willSendRequest:)];
     55    // resourceWithID:
     56    // type:
     57    // _WKFrameHandle frame:
     58    // _WKFrameHandle parentFrame:
     59   
     60    m_delegateMethods.didSendRequest = [delegate respondsToSelector:@selector(webView:resourceLoad:didSendRequest:)];
     61    m_delegateMethods.didPerformHTTPRedirection = [delegate respondsToSelector:@selector(webView:resourceLoad:didPerformHTTPRedirection:newRequest:)];
     62    m_delegateMethods.didReceiveChallenge = [delegate respondsToSelector:@selector(webView:resourceLoad:didReceiveChallenge:)];
     63    m_delegateMethods.didReceiveResponse = [delegate respondsToSelector:@selector(webView:resourceLoad:didReceiveResponse:)];
     64    m_delegateMethods.didCompleteWithError = [delegate respondsToSelector:@selector(webView:resourceLoad:didCompleteWithError:)];
    5565}
    5666
     
    6272ResourceLoadDelegate::ResourceLoadClient::~ResourceLoadClient() = default;
    6373
    64 void ResourceLoadDelegate::ResourceLoadClient::willSendRequest(const WebCore::ResourceRequest& request) const
     74void ResourceLoadDelegate::ResourceLoadClient::didSendRequest(WebKit::ResourceLoadInfo&& loadInfo, WebCore::ResourceRequest&& request) const
    6575{
    66     if (!m_resourceLoadDelegate.m_delegateMethods.willSendRequest)
     76    if (!m_resourceLoadDelegate.m_delegateMethods.didSendRequest)
    6777        return;
    6878
     
    7181        return;
    7282
    73     [delegate webView:m_resourceLoadDelegate.m_webView.get().get() willSendRequest:request.nsURLRequest(HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)];
     83    [delegate webView:m_resourceLoadDelegate.m_webView.get().get() resourceLoad:wrapper(API::ResourceLoadInfo::create(WTFMove(loadInfo)).get()) didSendRequest:request.nsURLRequest(HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)];
     84}
     85
     86void ResourceLoadDelegate::ResourceLoadClient::didPerformHTTPRedirection(WebKit::ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response, WebCore::ResourceRequest&& request) const
     87{
     88    if (!m_resourceLoadDelegate.m_delegateMethods.didPerformHTTPRedirection)
     89        return;
     90
     91    auto delegate = m_resourceLoadDelegate.m_delegate.get();
     92    if (!delegate)
     93        return;
     94
     95    [delegate webView:m_resourceLoadDelegate.m_webView.get().get() resourceLoad:wrapper(API::ResourceLoadInfo::create(WTFMove(loadInfo)).get()) didPerformHTTPRedirection:response.nsURLResponse() newRequest:request.nsURLRequest(HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)];
     96}
     97
     98void ResourceLoadDelegate::ResourceLoadClient::didReceiveChallenge(WebKit::ResourceLoadInfo&& loadInfo, WebKit::AuthenticationChallengeProxy& challenge) const
     99{
     100    if (!m_resourceLoadDelegate.m_delegateMethods.didReceiveChallenge)
     101        return;
     102
     103    auto delegate = m_resourceLoadDelegate.m_delegate.get();
     104    if (!delegate)
     105        return;
     106
     107    [delegate webView:m_resourceLoadDelegate.m_webView.get().get() resourceLoad:wrapper(API::ResourceLoadInfo::create(WTFMove(loadInfo)).get()) didReceiveChallenge:wrapper(challenge)];
     108}
     109
     110void ResourceLoadDelegate::ResourceLoadClient::didReceiveResponse(WebKit::ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response) const
     111{
     112    if (!m_resourceLoadDelegate.m_delegateMethods.didReceiveResponse)
     113        return;
     114
     115    auto delegate = m_resourceLoadDelegate.m_delegate.get();
     116    if (!delegate)
     117        return;
     118
     119    [delegate webView:m_resourceLoadDelegate.m_webView.get().get() resourceLoad:wrapper(API::ResourceLoadInfo::create(WTFMove(loadInfo)).get()) didReceiveResponse:response.nsURLResponse()];
     120}
     121
     122void ResourceLoadDelegate::ResourceLoadClient::didCompleteWithError(WebKit::ResourceLoadInfo&& loadInfo, WebCore::ResourceError&& error) const
     123{
     124    if (!m_resourceLoadDelegate.m_delegateMethods.didCompleteWithError)
     125        return;
     126
     127    auto delegate = m_resourceLoadDelegate.m_delegate.get();
     128    if (!delegate)
     129        return;
     130
     131    [delegate webView:m_resourceLoadDelegate.m_webView.get().get() resourceLoad:wrapper(API::ResourceLoadInfo::create(WTFMove(loadInfo)).get()) didCompleteWithError:error.nsError()];
    74132}
    75133
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r254342 r254345  
    453453}
    454454
    455 void NetworkProcessProxy::pageWillSendRequest(WebPageProxyIdentifier pageID, const WebCore::ResourceRequest& request)
     455void NetworkProcessProxy::resourceLoadDidSendRequest(WebPageProxyIdentifier pageID, ResourceLoadInfo&& loadInfo, WebCore::ResourceRequest&& request)
    456456{
    457457    auto* page = WebProcessProxy::webPage(pageID);
     
    459459        return;
    460460
    461     page->willSendRequest(request);
     461    page->resourceLoadDidSendRequest(WTFMove(loadInfo), WTFMove(request));
     462}
     463
     464void NetworkProcessProxy::resourceLoadDidPerformHTTPRedirection(WebPageProxyIdentifier pageID, ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response, WebCore::ResourceRequest&& request)
     465{
     466    auto* page = WebProcessProxy::webPage(pageID);
     467    if (!page)
     468        return;
     469
     470    page->resourceLoadDidPerformHTTPRedirection(WTFMove(loadInfo), WTFMove(response), WTFMove(request));
     471}
     472
     473void NetworkProcessProxy::resourceLoadDidReceiveChallenge(WebPageProxyIdentifier pageID, ResourceLoadInfo&& loadInfo, WebCore::AuthenticationChallenge&& challenge)
     474{
     475    auto* page = WebProcessProxy::webPage(pageID);
     476    if (!page)
     477        return;
     478
     479    auto challengeProxy = AuthenticationChallengeProxy::create(WTFMove(challenge), 0, *connection(), nullptr);
     480    page->resourceLoadDidReceiveChallenge(WTFMove(loadInfo), challengeProxy.get());
     481}
     482
     483void NetworkProcessProxy::resourceLoadDidReceiveResponse(WebPageProxyIdentifier pageID, ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response)
     484{
     485    auto* page = WebProcessProxy::webPage(pageID);
     486    if (!page)
     487        return;
     488
     489    page->resourceLoadDidReceiveResponse(WTFMove(loadInfo), WTFMove(response));
     490}
     491
     492void NetworkProcessProxy::resourceLoadDidCompleteWithError(WebPageProxyIdentifier pageID, ResourceLoadInfo&& loadInfo, WebCore::ResourceError&& error)
     493{
     494    auto* page = WebProcessProxy::webPage(pageID);
     495    if (!page)
     496        return;
     497
     498    page->resourceLoadDidCompleteWithError(WTFMove(loadInfo), WTFMove(error));
    462499}
    463500
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r254183 r254345  
    6565class DownloadProxyMap;
    6666class WebProcessPool;
     67class WebUserContentControllerProxy;
     68
    6769enum class ShouldGrandfatherStatistics : bool;
    6870enum class StorageAccessStatus : uint8_t;
    6971enum class WebsiteDataFetchOption;
    7072enum class WebsiteDataType;
     73
    7174struct NetworkProcessCreationParameters;
    72 class WebUserContentControllerProxy;
     75struct ResourceLoadInfo;
    7376struct WebsiteData;
    7477
     
    202205    void resetQuota(PAL::SessionID, CompletionHandler<void()>&&);
    203206
    204     void pageWillSendRequest(WebPageProxyIdentifier, const WebCore::ResourceRequest&);
     207    void resourceLoadDidSendRequest(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::ResourceRequest&&);
     208    void resourceLoadDidPerformHTTPRedirection(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::ResourceResponse&&, WebCore::ResourceRequest&&);
     209    void resourceLoadDidReceiveChallenge(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::AuthenticationChallenge&&);
     210    void resourceLoadDidReceiveResponse(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::ResourceResponse&&);
     211    void resourceLoadDidCompleteWithError(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::ResourceError&&);
    205212
    206213private:
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r254183 r254345  
    6969    RequestStorageSpace(PAL::SessionID sessionID, struct WebCore::ClientOrigin origin, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired) -> (Optional<uint64_t> newQuota) Async
    7070   
    71     PageWillSendRequest(WebKit::WebPageProxyIdentifier pageIdentifier, WebCore::ResourceRequest request)
     71    ResourceLoadDidSendRequest(WebKit::WebPageProxyIdentifier pageIdentifier, struct WebKit::ResourceLoadInfo resourceLoadInfo, WebCore::ResourceRequest request)
     72    ResourceLoadDidPerformHTTPRedirection(WebKit::WebPageProxyIdentifier pageIdentifier, struct WebKit::ResourceLoadInfo resourceLoadInfo, WebCore::ResourceResponse resourceResponse, WebCore::ResourceRequest request)
     73    ResourceLoadDidReceiveChallenge(WebKit::WebPageProxyIdentifier pageIdentifier, struct WebKit::ResourceLoadInfo resourceLoadInfo, WebCore::AuthenticationChallenge challenge)
     74    ResourceLoadDidReceiveResponse(WebKit::WebPageProxyIdentifier pageIdentifier, struct WebKit::ResourceLoadInfo resourceLoadInfo, WebCore::ResourceResponse response)
     75    ResourceLoadDidCompleteWithError(WebKit::WebPageProxyIdentifier pageIdentifier, struct WebKit::ResourceLoadInfo resourceLoadInfo, WebCore::ResourceError error)
    7276}
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r254312 r254345  
    59225922}
    59235923
    5924 void WebPageProxy::willSendRequest(const WebCore::ResourceRequest& request)
     5924void WebPageProxy::resourceLoadDidSendRequest(ResourceLoadInfo&& loadInfo, WebCore::ResourceRequest&& request)
    59255925{
    59265926    if (m_resourceLoadClient)
    5927         m_resourceLoadClient->willSendRequest(request);
     5927        m_resourceLoadClient->didSendRequest(WTFMove(loadInfo), WTFMove(request));
     5928}
     5929
     5930void WebPageProxy::resourceLoadDidPerformHTTPRedirection(ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response, WebCore::ResourceRequest&& request)
     5931{
     5932    if (m_resourceLoadClient)
     5933        m_resourceLoadClient->didPerformHTTPRedirection(WTFMove(loadInfo), WTFMove(response), WTFMove(request));
     5934}
     5935
     5936void WebPageProxy::resourceLoadDidReceiveChallenge(ResourceLoadInfo&& loadInfo, WebKit::AuthenticationChallengeProxy& challenge)
     5937{
     5938    if (m_resourceLoadClient)
     5939        m_resourceLoadClient->didReceiveChallenge(WTFMove(loadInfo), challenge);
     5940}
     5941
     5942void WebPageProxy::resourceLoadDidReceiveResponse(ResourceLoadInfo&& loadInfo, WebCore::ResourceResponse&& response)
     5943{
     5944    if (m_resourceLoadClient)
     5945        m_resourceLoadClient->didReceiveResponse(WTFMove(loadInfo), WTFMove(response));
     5946}
     5947
     5948void WebPageProxy::resourceLoadDidCompleteWithError(ResourceLoadInfo&& loadInfo, WebCore::ResourceError&& error)
     5949{
     5950    if (m_resourceLoadClient)
     5951        m_resourceLoadClient->didCompleteWithError(WTFMove(loadInfo), WTFMove(error));
    59285952}
    59295953
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r254312 r254345  
    326326struct PrintInfo;
    327327struct PDFContextMenu;
     328struct ResourceLoadInfo;
    328329struct WebAutocorrectionData;
    329330struct WebHitTestResultData;
     
    471472    WebInspectorProxy* inspector() const;
    472473
    473     void willSendRequest(const WebCore::ResourceRequest&);
     474    void resourceLoadDidSendRequest(ResourceLoadInfo&&, WebCore::ResourceRequest&&);
     475    void resourceLoadDidPerformHTTPRedirection(ResourceLoadInfo&&, WebCore::ResourceResponse&&, WebCore::ResourceRequest&&);
     476    void resourceLoadDidReceiveChallenge(ResourceLoadInfo&&, WebKit::AuthenticationChallengeProxy&);
     477    void resourceLoadDidReceiveResponse(ResourceLoadInfo&&, WebCore::ResourceResponse&&);
     478    void resourceLoadDidCompleteWithError(ResourceLoadInfo&&, WebCore::ResourceError&&);
    474479
    475480    void didChangeInspectorFrontendCount(unsigned count) { m_inspectorFrontendCount = count; }
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r254081 r254345  
    4949#import "RemoteScrollingCoordinatorProxy.h"
    5050#import "ShareableResource.h"
     51#import "UIKitSPI.h"
    5152#import "UserData.h"
    5253#import "UserInterfaceIdiom.h"
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r254307 r254345  
    11711171                5CB2378E1DF0E0D300117AA3 /* _WKWebsitePoliciesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB2378D1DF0E0C200117AA3 /* _WKWebsitePoliciesInternal.h */; };
    11721172                5CB7AFE023C52CE500E49CF3 /* _WKResourceLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB7AFDF23C52CBC00E49CF3 /* _WKResourceLoadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1173                5CB7AFE723C6820700E49CF3 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */; };
     1174                5CB7AFE823C69B6100E49CF3 /* _WKResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB7AFE323C67D3700E49CF3 /* _WKResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11731175                5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
    11741176                5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */; };
     
    39083910                5CB7AFDE23C5273D00E49CF3 /* ResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoadDelegate.mm; sourceTree = "<group>"; };
    39093911                5CB7AFDF23C52CBC00E49CF3 /* _WKResourceLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadDelegate.h; sourceTree = "<group>"; };
     3912                5CB7AFE223C67D3700E49CF3 /* _WKResourceLoadInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKResourceLoadInfo.mm; sourceTree = "<group>"; };
     3913                5CB7AFE323C67D3700E49CF3 /* _WKResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadInfo.h; sourceTree = "<group>"; };
     3914                5CB7AFE423C67D6400E49CF3 /* APIResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIResourceLoadInfo.h; sourceTree = "<group>"; };
     3915                5CB7AFE523C67DF900E49CF3 /* _WKResourceLoadInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadInfoInternal.h; sourceTree = "<group>"; };
     3916                5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; };
    39103917                5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
    39113918                5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
     
    39203927                5CD2864F1E722F440094FDC8 /* WKContentRuleListStoreInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentRuleListStoreInternal.h; sourceTree = "<group>"; };
    39213928                5CD286501E722F440094FDC8 /* WKContentRuleListStorePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentRuleListStorePrivate.h; sourceTree = "<group>"; };
     3929                5CD748B523C8EB190092A9B5 /* NetworkResourceLoadIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkResourceLoadIdentifier.h; sourceTree = "<group>"; };
    39223930                5CE0C366229F2D3D003695F0 /* APIContextMenuElementInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIContextMenuElementInfo.cpp; sourceTree = "<group>"; };
    39233931                5CE0C367229F2D3E003695F0 /* APIContextMenuElementInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIContextMenuElementInfo.h; sourceTree = "<group>"; };
     
    56185626                                1ADCB868189831B30022EE5A /* NavigationActionData.cpp */,
    56195627                                1ADCB869189831B30022EE5A /* NavigationActionData.h */,
     5628                                5CD748B523C8EB190092A9B5 /* NetworkResourceLoadIdentifier.h */,
    56205629                                9BC59D6D1EFCDC6D001E8D09 /* OptionalCallbackID.h */,
    56215630                                7AFBD36E21E546E3005DBACB /* PersistencyUtils.cpp */,
     
    56275636                                463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */,
    56285637                                F6A0C13F13281E6E0070430F /* ResourceCachesToClear.h */,
     5638                                5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */,
    56295639                                410482CB1DDD2FB500F006D0 /* RTCNetwork.cpp */,
    56305640                                410482CC1DDD2FB500F006D0 /* RTCNetwork.h */,
     
    67836793                                990E1E082384A88B004602DF /* _WKRemoteWebInspectorViewControllerPrivate.h */,
    67846794                                5CB7AFDF23C52CBC00E49CF3 /* _WKResourceLoadDelegate.h */,
     6795                                5CB7AFE323C67D3700E49CF3 /* _WKResourceLoadInfo.h */,
     6796                                5CB7AFE223C67D3700E49CF3 /* _WKResourceLoadInfo.mm */,
     6797                                5CB7AFE523C67DF900E49CF3 /* _WKResourceLoadInfoInternal.h */,
    67856798                                49FBEFFB239ADB1800BD032F /* _WKResourceLoadStatisticsFirstParty.h */,
    67866799                                49FBEFFC239B011D00BD032F /* _WKResourceLoadStatisticsFirstParty.mm */,
     
    84938506                                7CE4D21E1A4914CA00C7F152 /* APIProcessPoolConfiguration.h */,
    84948507                                5CB7AFDA23C43E6400E49CF3 /* APIResourceLoadClient.h */,
     8508                                5CB7AFE423C67D6400E49CF3 /* APIResourceLoadInfo.h */,
    84958509                                49BCA19123A177660028A836 /* APIResourceLoadStatisticsFirstParty.h */,
    84968510                                49BCA19623A18F620028A836 /* APIResourceLoadStatisticsThirdParty.h */,
     
    98409854                                1F604BAA1889FBB800EE0395 /* _WKRenderingProgressEventsInternal.h in Headers */,
    98419855                                5CB7AFE023C52CE500E49CF3 /* _WKResourceLoadDelegate.h in Headers */,
     9856                                5CB7AFE823C69B6100E49CF3 /* _WKResourceLoadInfo.h in Headers */,
    98429857                                49FBF001239B1F8D00BD032F /* _WKResourceLoadStatisticsFirstParty.h in Headers */,
    98439858                                49BCA19523A18CFD0028A836 /* _WKResourceLoadStatisticsFirstPartyInternal.h in Headers */,
     
    1030010315                                A55BA8251BA25CFB007CD33D /* RemoteWebInspectorProxyMessages.h in Headers */,
    1030110316                                A55BA8171BA23E12007CD33D /* RemoteWebInspectorUI.h in Headers */,
     10317                                5CB7AFE723C6820700E49CF3 /* ResourceLoadInfo.h in Headers */,
    1030210318                                6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
    1030310319                                6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r254183 r254345  
    527527void WebLoaderStrategy::loadResourceSynchronously(FrameLoader& frameLoader, unsigned long resourceLoadIdentifier, const ResourceRequest& request, ClientCredentialPolicy clientCredentialPolicy,  const FetchOptions& options, const HTTPHeaderMap& originalRequestHeaders, ResourceError& error, ResourceResponse& response, Vector<char>& data)
    528528{
    529     WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frameLoader.client());
    530     WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
    531     WebPage* webPage = webFrame ? webFrame->page() : nullptr;
     529    auto* webFrameLoaderClient = toWebFrameLoaderClient(frameLoader.client());
     530    auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
     531    auto* webPage = webFrame ? webFrame->page() : nullptr;
     532    auto* page = webPage ? webPage->corePage() : nullptr;
    532533
    533534    auto webPageProxyID = webPage ? webPage->webPageProxyIdentifier() : WebPageProxyIdentifier { };
     
    580581    }
    581582    loadParameters.originalRequestHeaders = originalRequestHeaders;
     583    if (page)
     584        loadParameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
    582585
    583586    data.shrink(0);
     
    592595    if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad(loadParameters), Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::Reply(error, response, data), 0)) {
    593596        WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR_IF_ALLOWED("loadResourceSynchronously: failed sending synchronous network process message");
    594         if (auto* page = webPage ? webPage->corePage() : nullptr)
     597        if (page)
    595598            page->diagnosticLoggingClient().logDiagnosticMessage(WebCore::DiagnosticLoggingKeys::internalErrorKey(), WebCore::DiagnosticLoggingKeys::synchronousMessageFailedKey(), WebCore::ShouldSample::No);
    596599        response = ResourceResponse();
     
    645648            loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders();
    646649    }
     650    if (auto* page = document->page())
     651        loadParameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
    647652
    648653#if ENABLE(CONTENT_EXTENSIONS)
  • trunk/Tools/ChangeLog

    r254344 r254345  
     12020-01-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        Expand _WKResourceLoadDelegate callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=206037
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
     9        (-[TestResourceLoadDelegate webView:resourceLoad:didSendRequest:]):
     10        (-[TestResourceLoadDelegate webView:resourceLoad:didPerformHTTPRedirection:newRequest:]):
     11        (-[TestResourceLoadDelegate webView:resourceLoad:didReceiveChallenge:]):
     12        (-[TestResourceLoadDelegate webView:resourceLoad:didReceiveResponse:]):
     13        (-[TestResourceLoadDelegate webView:resourceLoad:didCompleteWithError:]):
     14        (TEST):
     15        (-[TestResourceLoadDelegate webView:willSendRequest:]): Deleted.
     16        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
     17        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
     18        (TEST):
     19        * TestWebKitAPI/cocoa/HTTPServer.h:
     20        (TestWebKitAPI::HTTPServer::HTTPResponse::HTTPResponse):
     21        Add the ability to have non-200 status codes in responses.
     22        Also switch the order of parameters to reflect the fact that header fields are sent before the body.
     23        * TestWebKitAPI/cocoa/HTTPServer.mm:
     24        (TestWebKitAPI::statusText):
     25        (TestWebKitAPI::HTTPServer::respondToRequests):
     26
    1272020-01-10  Alex Christensen  <achristensen@webkit.org>
    228
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm

    r254183 r254345  
    2626#import "config.h"
    2727
     28#import "HTTPServer.h"
    2829#import "PlatformUtilities.h"
     30#import "TCPServer.h"
    2931#import "TestNavigationDelegate.h"
     32#import "TestWKWebView.h"
    3033#import <WebKit/WKWebViewPrivate.h>
    3134#import <WebKit/WebKit.h>
    3235#import <WebKit/_WKResourceLoadDelegate.h>
     36#import <WebKit/_WKResourceLoadInfo.h>
    3337#import <wtf/RetainPtr.h>
    3438
    3539@interface TestResourceLoadDelegate : NSObject <_WKResourceLoadDelegate>
    3640
    37 @property (nonatomic, copy) void (^willSendRequest)(WKWebView *, NSURLRequest *);
     41@property (nonatomic, copy) void (^didSendRequest)(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *);
     42@property (nonatomic, copy) void (^didPerformHTTPRedirection)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *, NSURLRequest *);
     43@property (nonatomic, copy) void (^didReceiveChallenge)(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *);
     44@property (nonatomic, copy) void (^didReceiveResponse)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *);
     45@property (nonatomic, copy) void (^didCompleteWithError)(WKWebView *, _WKResourceLoadInfo *, NSError *);
    3846
    3947@end
     
    4149@implementation TestResourceLoadDelegate
    4250
    43 - (void)webView:(WKWebView *)webView willSendRequest:(NSURLRequest *)request
    44 {
    45     if (_willSendRequest)
    46         _willSendRequest(webView, request);
     51- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didSendRequest:(NSURLRequest *)request
     52{
     53    if (_didSendRequest)
     54        _didSendRequest(webView, resourceLoad, request);
     55}
     56
     57- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didPerformHTTPRedirection:(NSURLResponse *)response newRequest:(NSURLRequest *)request
     58{
     59    if (_didPerformHTTPRedirection)
     60        _didPerformHTTPRedirection(webView, resourceLoad, response, request);
     61}
     62
     63- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
     64{
     65    if (_didReceiveChallenge)
     66        _didReceiveChallenge(webView, resourceLoad, challenge);
     67}
     68
     69- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveResponse:(NSURLResponse *)response
     70{
     71    if (_didReceiveResponse)
     72        _didReceiveResponse(webView, resourceLoad, response);
     73}
     74
     75- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didCompleteWithError:(NSError *)error
     76{
     77    if (_didCompleteWithError)
     78        _didCompleteWithError(webView, resourceLoad, error);
    4779}
    4880
     
    6395    auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
    6496    [webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
    65     [resourceLoadDelegate setWillSendRequest:^(WKWebView *, NSURLRequest *request) {
     97    [resourceLoadDelegate setDidSendRequest:^(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *request) {
    6698        requestFromDelegate = request;
    6799    }];
     
    73105    EXPECT_WK_STREQ(requestLoaded.get().URL.absoluteString, requestFromDelegate.get().URL.absoluteString);
    74106}
     107
     108#if HAVE(NETWORK_FRAMEWORK)
     109
     110TEST(ResourceLoadDelegate, BeaconAndSyncXHR)
     111{
     112    TestWebKitAPI::HTTPServer server({
     113        { "/", { "hello" } },
     114        { "/xhrTarget", { "hi" } },
     115        { "/beaconTarget", { "hi" } },
     116    });
     117
     118    auto webView = adoptNS([TestWKWebView new]);
     119    [webView synchronouslyLoadRequest:server.request()];
     120
     121    __block RetainPtr<NSURLRequest> requestFromDelegate;
     122    __block bool receivedCallback = false;
     123    auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
     124    [webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
     125    [resourceLoadDelegate setDidSendRequest:^(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *request) {
     126        requestFromDelegate = request;
     127        receivedCallback = true;
     128    }];
     129
     130    [webView evaluateJavaScript:@"navigator.sendBeacon('/beaconTarget')" completionHandler:nil];
     131    TestWebKitAPI::Util::run(&receivedCallback);
     132    EXPECT_WK_STREQ("/beaconTarget", requestFromDelegate.get().URL.path);
     133
     134    receivedCallback = false;
     135    [webView evaluateJavaScript:
     136        @"var request = new XMLHttpRequest();"
     137        "var asynchronous = false;"
     138        "request.open('GET', 'xhrTarget', asynchronous);"
     139        "request.send();" completionHandler:nil];
     140    TestWebKitAPI::Util::run(&receivedCallback);
     141    EXPECT_WK_STREQ("/xhrTarget", requestFromDelegate.get().URL.path);
     142}
     143
     144TEST(ResourceLoadDelegate, Redirect)
     145{
     146    TestWebKitAPI::HTTPServer server({
     147        { "/", { 301, {{ "Location", "/redirectTarget" }} } },
     148        { "/redirectTarget", { "hi" } },
     149    });
     150
     151    __block bool done = false;
     152    auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
     153    [resourceLoadDelegate setDidPerformHTTPRedirection:^(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *response, NSURLRequest *request) {
     154        EXPECT_WK_STREQ(response.URL.path, "/");
     155        EXPECT_WK_STREQ(request.URL.path, "/redirectTarget");
     156        done = true;
     157    }];
     158
     159    auto webView = adoptNS([WKWebView new]);
     160    [webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
     161    [webView loadRequest:server.request()];
     162    TestWebKitAPI::Util::run(&done);
     163}
     164
     165TEST(ResourceLoadDelegate, LoadInfo)
     166{
     167    TestWebKitAPI::HTTPServer server({
     168        { "/", { "<iframe src='iframeSrc'></iframe>" } },
     169        { "/iframeSrc", { "<script>fetch('fetchTarget')</script>" } },
     170        { "/fetchTarget", { "hi" } },
     171    });
     172
     173    enum class Callback {
     174        DidSendRequest,
     175        DidReceiveResponse,
     176        DidCompleteWithError,
     177    };
     178
     179    __block Vector<Callback> callbacks;
     180    __block Vector<RetainPtr<WKWebView>> webViews;
     181    __block Vector<RetainPtr<_WKResourceLoadInfo>> loadInfos;
     182    __block Vector<RetainPtr<id>> otherParameters;
     183
     184    __block size_t resourceCompletionCount = 0;
     185    auto delegate = adoptNS([TestResourceLoadDelegate new]);
     186    [delegate setDidSendRequest:^(WKWebView *webView, _WKResourceLoadInfo *loadInfo, NSURLRequest *request) {
     187        callbacks.append(Callback::DidSendRequest);
     188        webViews.append(webView);
     189        loadInfos.append(loadInfo);
     190        otherParameters.append(request);
     191    }];
     192    [delegate setDidReceiveResponse:^(WKWebView *webView, _WKResourceLoadInfo *loadInfo, NSURLResponse *response) {
     193        callbacks.append(Callback::DidReceiveResponse);
     194        webViews.append(webView);
     195        loadInfos.append(loadInfo);
     196        otherParameters.append(response);
     197    }];
     198    [delegate setDidCompleteWithError:^(WKWebView *webView, _WKResourceLoadInfo *loadInfo, NSError *error) {
     199        callbacks.append(Callback::DidCompleteWithError);
     200        webViews.append(webView);
     201        loadInfos.append(loadInfo);
     202        otherParameters.append(error);
     203        resourceCompletionCount++;
     204    }];
     205
     206    auto webView = adoptNS([WKWebView new]);
     207    [webView _setResourceLoadDelegate:delegate.get()];
     208    [webView loadRequest:server.request()];
     209    while (resourceCompletionCount < 3)
     210        TestWebKitAPI::Util::spinRunLoop();
     211
     212    Vector<Callback> expectedCallbacks {
     213        Callback::DidSendRequest,
     214        Callback::DidReceiveResponse,
     215        Callback::DidCompleteWithError,
     216        Callback::DidSendRequest,
     217        Callback::DidReceiveResponse,
     218        Callback::DidCompleteWithError,
     219        Callback::DidSendRequest,
     220        Callback::DidReceiveResponse,
     221        Callback::DidCompleteWithError
     222    };
     223    EXPECT_EQ(callbacks, expectedCallbacks);
     224
     225    EXPECT_EQ(webViews.size(), 9ull);
     226    for (auto& view : webViews)
     227        EXPECT_EQ(webView.get(), view.get());
     228
     229    EXPECT_EQ(loadInfos.size(), 9ull);
     230    EXPECT_EQ(loadInfos[0].get().resourceLoadID, loadInfos[1].get().resourceLoadID);
     231    EXPECT_EQ(loadInfos[0].get().resourceLoadID, loadInfos[2].get().resourceLoadID);
     232    EXPECT_NE(loadInfos[0].get().resourceLoadID, loadInfos[3].get().resourceLoadID);
     233    EXPECT_EQ(loadInfos[3].get().resourceLoadID, loadInfos[4].get().resourceLoadID);
     234    EXPECT_EQ(loadInfos[3].get().resourceLoadID, loadInfos[5].get().resourceLoadID);
     235    EXPECT_NE(loadInfos[3].get().resourceLoadID, loadInfos[6].get().resourceLoadID);
     236    EXPECT_EQ(loadInfos[6].get().resourceLoadID, loadInfos[7].get().resourceLoadID);
     237    EXPECT_EQ(loadInfos[6].get().resourceLoadID, loadInfos[8].get().resourceLoadID);
     238    EXPECT_NE(loadInfos[6].get().resourceLoadID, loadInfos[0].get().resourceLoadID);
     239
     240    EXPECT_EQ(otherParameters.size(), 9ull);
     241    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[0] class]), "NSMutableURLRequest");
     242    EXPECT_WK_STREQ([otherParameters[0] URL].path, "/");
     243    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[1] class]), "NSHTTPURLResponse");
     244    EXPECT_WK_STREQ([otherParameters[1] URL].path, "/");
     245    EXPECT_EQ(otherParameters[2], nil);
     246    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[3] class]), "NSMutableURLRequest");
     247    EXPECT_WK_STREQ([otherParameters[3] URL].path, "/iframeSrc");
     248    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[4] class]), "NSHTTPURLResponse");
     249    EXPECT_WK_STREQ([otherParameters[4] URL].path, "/iframeSrc");
     250    EXPECT_EQ(otherParameters[5], nil);
     251    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[6] class]), "NSMutableURLRequest");
     252    EXPECT_WK_STREQ([otherParameters[6] URL].path, "/fetchTarget");
     253    EXPECT_WK_STREQ(NSStringFromClass([otherParameters[7] class]), "NSHTTPURLResponse");
     254    EXPECT_WK_STREQ([otherParameters[7] URL].path, "/fetchTarget");
     255    EXPECT_EQ(otherParameters[8], nil);
     256}
     257
     258#endif // HAVE(NETWORK_FRAMEWORK)
     259
     260TEST(ResourceLoadDelegate, Challenge)
     261{
     262    using namespace TestWebKitAPI;
     263    TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL* ssl) {
     264        EXPECT_TRUE(!!ssl); // Connection should succeed after a server trust challenge.
     265        // Send nothing to make the resource load fail.
     266    });
     267
     268    auto navigationDelegate = adoptNS([TestNavigationDelegate new]);
     269    [navigationDelegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
     270        EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
     271        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
     272    }];
     273
     274    __block bool receivedErrorNotification = false;
     275    __block bool receivedChallengeNotificiation = false;
     276    auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
     277    [resourceLoadDelegate setDidReceiveChallenge:^(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *challenge) {
     278        EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
     279        receivedChallengeNotificiation = true;
     280    }];
     281    [resourceLoadDelegate setDidCompleteWithError:^(WKWebView *, _WKResourceLoadInfo *, NSError *error) {
     282        EXPECT_EQ(error.code, kCFURLErrorCannotConnectToHost);
     283        EXPECT_WK_STREQ(error.domain, NSURLErrorDomain);
     284        receivedErrorNotification = true;
     285    }];
     286
     287    auto webView = adoptNS([WKWebView new]);
     288    [webView setNavigationDelegate:navigationDelegate.get()];
     289    [webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
     290    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]]];
     291    TestWebKitAPI::Util::run(&receivedErrorNotification);
     292    EXPECT_TRUE(receivedChallengeNotificiation);
     293}
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm

    r254342 r254345  
    17061706    TestWebKitAPI::HTTPServer server({
    17071707        { "/", { mainBytes } },
    1708         { "/sw.js", { scriptBytes, {{ "Content-Type", "application/javascript" }} } },
     1708        { "/sw.js", { {{ "Content-Type", "application/javascript" }}, scriptBytes } },
    17091709    });
    17101710
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm

    r253952 r254345  
    579579        { "/index.html", { "<html manifest='test.appcache'>" } },
    580580        { "/test.appcache", { "CACHE MANIFEST\nindex.html\ntest.mp4\n" } },
    581         { "/test.mp4", { "test!", {{ "Content-Type", "video/test" }}}},
     581        { "/test.mp4", { {{ "Content-Type", "video/test" }}, "test!" }},
    582582    });
    583583   
  • trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.h

    r252476 r254345  
    5353    HTTPResponse(String&& body)
    5454        : body(WTFMove(body)) { }
    55     HTTPResponse(String&& body, HashMap<String, String>&& headerFields)
    56         : body(WTFMove(body))
    57         , headerFields(WTFMove(headerFields)) { }
     55    HTTPResponse(HashMap<String, String>&& headerFields, String&& body)
     56        : headerFields(WTFMove(headerFields))
     57        , body(WTFMove(body)) { }
     58    HTTPResponse(unsigned statusCode, HashMap<String, String>&& headerFields, String&& body = { })
     59        : statusCode(statusCode)
     60        , headerFields(WTFMove(headerFields))
     61        , body(WTFMove(body)) { }
    5862
    5963    HTTPResponse(const HTTPResponse&) = default;
     
    6367    HTTPResponse& operator=(HTTPResponse&&) = default;
    6468   
     69    unsigned statusCode { 200 };
     70    HashMap<String, String> headerFields;
    6571    String body;
    66     HashMap<String, String> headerFields;
    6772};
    6873
  • trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm

    r253444 r254345  
    5353}
    5454
     55static String statusText(unsigned statusCode)
     56{
     57    switch (statusCode) {
     58    case 200:
     59        return "OK"_s;
     60    case 301:
     61        return "Moved Permanently"_s;
     62    }
     63    ASSERT_NOT_REACHED();
     64    return { };
     65}
     66
    5567void HTTPServer::respondToRequests(nw_connection_t connection)
    5668{
     
    7789        auto response = m_requestResponseMap.get(path);
    7890        StringBuilder responseBuilder;
    79         responseBuilder.append("HTTP/1.1 200 OK\r\nContent-Length: ");
     91        responseBuilder.append("HTTP/1.1 ");
     92        responseBuilder.appendNumber(response.statusCode);
     93        responseBuilder.append(' ');
     94        responseBuilder.append(statusText(response.statusCode));
     95        responseBuilder.append("\r\nContent-Length: ");
    8096        responseBuilder.appendNumber(response.body.length());
    8197        responseBuilder.append("\r\n");
Note: See TracChangeset for help on using the changeset viewer.