Unreviewed, rolling out r245401.
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKWebpagePreferences.mm
index 4c99139..6a36b1b 100644 (file)
 #import "config.h"
 #import "WKWebpagePreferences.h"
 
-#import "APICustomHeaderFields.h"
 #import "WKWebpagePreferencesInternal.h"
 #import "WKWebsiteDataStoreInternal.h"
 #import "WebCompatibilityMode.h"
-#import "_WKCustomHeaderFieldsInternal.h"
 #import "_WKWebsitePoliciesInternal.h"
 #import <wtf/RetainPtr.h>
 
@@ -216,22 +214,26 @@ static _WKWebsiteDeviceOrientationAndMotionAccessPolicy toWKWebsiteDeviceOrienta
     }
 }
 
-- (NSArray<_WKCustomHeaderFields *> *)_customHeaderFields
+- (NSDictionary<NSString *, NSString *> *)_customHeaderFields
 {
     const auto& fields = _websitePolicies->customHeaderFields();
-    NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:fields.size()] autorelease];
+    auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]);
     for (const auto& field : fields)
-        [array addObject:wrapper(API::CustomHeaderFields::create(field))];
-    return array;
+        [dictionary setObject:field.value() forKey:field.name()];
+    return dictionary.autorelease();
 }
 
-- (void)_setCustomHeaderFields:(NSArray<_WKCustomHeaderFields *> *)fields
+- (void)_setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
 {
-    Vector<WebCore::CustomHeaderFields> vector;
-    vector.reserveInitialCapacity(fields.count);
-    for (_WKCustomHeaderFields *element in fields)
-        vector.uncheckedAppend(static_cast<API::CustomHeaderFields&>([element _apiObject]).coreFields());
-    _websitePolicies->setCustomHeaderFields(WTFMove(vector));
+    Vector<WebCore::HTTPHeaderField> parsedFields;
+    parsedFields.reserveInitialCapacity(fields.count);
+
+    for (NSString *name in fields) {
+        auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]);
+        if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
+            parsedFields.uncheckedAppend(WTFMove(*field));
+    }
+    _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields));
 }
 
 - (WKWebsiteDataStore *)_websiteDataStore