⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287056 in webkit


Ignore:
Timestamp:
Dec 14, 2021, 3:48:21 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Remove properties set by NSURLProtocol on NSURLRequest before serializing
https://bugs.webkit.org/show_bug.cgi?id=232332
<rdar://79227845>

Patch by Alex Christensen <achristensen@webkit.org> on 2021-12-14
Reviewed by Geoff Garen.

Source/WebCore/PAL:

  • pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
They exist to be used by NSURLProtocol. Serializing them can serialize a large amount of data,
so to be more efficient and hopefully run out of memory less, remove the properties before serializing.

  • Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:

(IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):

Source/WTF:

  • wtf/PlatformHave.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r287019 r287056  
     12021-12-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Remove properties set by NSURLProtocol on NSURLRequest before serializing
     4        https://bugs.webkit.org/show_bug.cgi?id=232332
     5        <rdar://79227845>
     6
     7        Reviewed by Geoff Garen.
     8
     9        * wtf/PlatformHave.h:
     10
    1112021-12-14  Darin Adler  <darin@apple.com>
    212
  • trunk/Source/WTF/wtf/PlatformHave.h

    r286958 r287056  
    935935    || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MAX_ALLOWED >= 80400)
    936936#define HAVE_RSA_PSS_OID 1
     937#define HAVE_NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES 1
    937938#endif
    938939
  • trunk/Source/WebCore/PAL/ChangeLog

    r287024 r287056  
     12021-12-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Remove properties set by NSURLProtocol on NSURLRequest before serializing
     4        https://bugs.webkit.org/show_bug.cgi?id=232332
     5        <rdar://79227845>
     6
     7        Reviewed by Geoff Garen.
     8
     9        * pal/spi/cf/CFNetworkSPI.h:
     10
    1112021-12-14  Andreu Botella  <andreu@andreubotella.com>
    212
  • trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h

    r285059 r287056  
    175175
    176176@interface NSMutableURLRequest ()
     177#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
     178- (void)_removeAllProtocolProperties;
     179#endif
    177180- (void)setContentDispositionEncodingFallbackArray:(NSArray *)theEncodingFallbackArray;
    178181- (void)setBoundInterfaceIdentifier:(NSString *)identifier;
     
    192195
    193196@interface NSURLRequest ()
     197#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
     198@property (nonatomic, readonly, nullable, retain) NSDictionary<NSString *, id> *_allProtocolProperties;
     199#endif
    194200+ (NSArray *)allowsSpecificHTTPSCertificateForHost:(NSString *)host;
    195201+ (void)setAllowsSpecificHTTPSCertificate:(NSArray *)allow forHost:(NSString *)host;
  • trunk/Source/WebKit/ChangeLog

    r287050 r287056  
     12021-12-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Remove properties set by NSURLProtocol on NSURLRequest before serializing
     4        https://bugs.webkit.org/show_bug.cgi?id=232332
     5        <rdar://79227845>
     6
     7        Reviewed by Geoff Garen.
     8
     9        NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
     10        They exist to be used by NSURLProtocol.  Serializing them can serialize a large amount of data,
     11        so to be more efficient and hopefully run out of memory less, remove the properties before serializing.
     12
     13        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
     14        (IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):
     15
    1162021-12-14  Jer Noble  <jer.noble@apple.com>
    217
  • trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm

    r287021 r287056  
    3838#import <WebCore/ResourceRequest.h>
    3939#import <WebCore/TextRecognitionResult.h>
     40#import <pal/spi/cf/CFNetworkSPI.h>
    4041#import <pal/spi/cf/CoreTextSPI.h>
    4142
     
    626627    // We don't send HTTP body over IPC for better performance.
    627628    // Also, it's not always possible to do, as streams can only be created in process that does networking.
    628     if ([requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream]) {
     629    bool hasHTTPBody = [requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream];
     630#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
     631    bool hasProtocolProperties = [requestToSerialize _allProtocolProperties];
     632#else
     633    bool hasProtocolProperties = false;
     634#endif
     635
     636    if (hasHTTPBody || hasProtocolProperties) {
    629637        auto mutableRequest = adoptNS([requestToSerialize mutableCopy]);
    630638        [mutableRequest setHTTPBody:nil];
    631639        [mutableRequest setHTTPBodyStream:nil];
     640#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
     641        [mutableRequest _removeAllProtocolProperties];
     642#endif
    632643        requestToSerialize = WTFMove(mutableRequest);
    633644    }
  • trunk/Tools/ChangeLog

    r287054 r287056  
     12021-12-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        Remove properties set by NSURLProtocol on NSURLRequest before serializing
     4        https://bugs.webkit.org/show_bug.cgi?id=232332
     5        <rdar://79227845>
     6
     7        Reviewed by Geoff Garen.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
     10        (TestWebKitAPI::TEST):
     11
    1122021-12-14  Jonathan Bedard  <jbedard@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm

    r285059 r287056  
    138138}
    139139
     140TEST(WebKit, LoadNSURLRequestWithProtocolProperties)
     141{
     142    auto request = adoptNS([[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"test:///"]]);
     143
     144    [NSURLProtocol setProperty:@"world" forKey:@"hello" inRequest:request.get()];
     145    auto handler = adoptNS([TestURLSchemeHandler new]);
     146    __block bool done = false;
     147    handler.get().startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) {
     148#if HAVE(NSURLREQUEST_REMOVE_ALL_PROTOCOL_PROPERTIES)
     149        EXPECT_FALSE([NSURLProtocol propertyForKey:@"hello" inRequest:task.request]);
     150#else
     151        EXPECT_TRUE([NSURLProtocol propertyForKey:@"hello" inRequest:task.request]);
     152#endif
     153        done = true;
     154    };
     155    auto configuration = adoptNS([WKWebViewConfiguration new]);
     156    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"test"];
     157    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
     158    [webView loadRequest:request.get()];
     159    Util::run(&done);
     160}
     161
    140162} // namespace TestWebKitAPI
    141163
Note: See TracChangeset for help on using the changeset viewer.