Title: [151994] trunk/Source/WebCore
- Revision
- 151994
- Author
- beid...@apple.com
- Date
- 2013-06-26 10:03:48 -0700 (Wed, 26 Jun 2013)
Log Message
[Mac] Document URL is not updated by HSTS
<rdar://problem/14241270> and https://bugs.webkit.org/show_bug.cgi?id=118003
Patch started by Alexey Proskuryakov, finished by Brady Eidson.
Reviewed by Brady Eidson and then Alexey Proskuryakov.
Synthesize a response and properly handle willSendRequest when the URL changes in a way that's typical for HSTS.
* platform/network/mac/WebCoreURLResponse:
* platform/network/mac/WebCoreURLResponse:
(WebCore::synthesizeRedirectResponseIfNecessary): Synthesize a redirect response and when the URL changes in a way that's
typical for HSTS connections.
* platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
(-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]): Call synthesizeRedirectResponseIfNecessary.
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151993 => 151994)
--- trunk/Source/WebCore/ChangeLog 2013-06-26 16:28:49 UTC (rev 151993)
+++ trunk/Source/WebCore/ChangeLog 2013-06-26 17:03:48 UTC (rev 151994)
@@ -1,3 +1,25 @@
+2013-06-26 Brady Eidson <beid...@apple.com>
+
+ [Mac] Document URL is not updated by HSTS
+ <rdar://problem/14241270> and https://bugs.webkit.org/show_bug.cgi?id=118003
+
+ Patch started by Alexey Proskuryakov, finished by Brady Eidson.
+
+ Reviewed by Brady Eidson and then Alexey Proskuryakov.
+
+ Synthesize a response and properly handle willSendRequest when the URL changes in a way that's typical for HSTS.
+
+ * platform/network/mac/WebCoreURLResponse:
+ * platform/network/mac/WebCoreURLResponse:
+ (WebCore::synthesizeRedirectResponseIfNecessary): Synthesize a redirect response and when the URL changes in a way that's
+ typical for HSTS connections.
+
+ * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+ (-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]): Call synthesizeRedirectResponseIfNecessary.
+
+ * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+ (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]): Ditto.
+
2013-06-26 Andrei Bucur <abu...@adobe.com>
[CSS Regions] fast/regions/seamless-iframe-flowed-into-regions.html asserts
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm (151993 => 151994)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2013-06-26 16:28:49 UTC (rev 151993)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2013-06-26 17:03:48 UTC (rev 151994)
@@ -66,6 +66,8 @@
if (!m_handle)
return nil;
+
+ redirectResponse = synthesizeRedirectResponseIfNecessary(connection, newRequest, redirectResponse);
// See <rdar://problem/5380697>. This is a workaround for a behavior change in CFNetwork where willSendRequest gets called more often.
if (!redirectResponse)
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm (151993 => 151994)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2013-06-26 16:28:49 UTC (rev 151993)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm 2013-06-26 17:03:48 UTC (rev 151994)
@@ -109,6 +109,8 @@
ASSERT(!isMainThread());
UNUSED_PARAM(connection);
+ redirectResponse = synthesizeRedirectResponseIfNecessary(connection, newRequest, redirectResponse);
+
// See <rdar://problem/5380697>. This is a workaround for a behavior change in CFNetwork where willSendRequest gets called more often.
if (!redirectResponse)
return newRequest;
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.h (151993 => 151994)
--- trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.h 2013-06-26 16:28:49 UTC (rev 151993)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.h 2013-06-26 17:03:48 UTC (rev 151994)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,8 +33,16 @@
- (CFURLResponseRef)_CFURLResponse;
- (void)_setMIMEType:(NSString *)type;
@end
-#endif
+@class NSURLConnection;
+@class NSURLRequest;
+@class NSURLResponse;
+
namespace WebCore {
+NSURLResponse *synthesizeRedirectResponseIfNecessary(NSURLConnection *, NSURLRequest *newRequest, NSURLResponse *redirectResponse);
+}
+#endif // __OBJC__
+
+namespace WebCore {
void adjustMIMETypeIfNecessary(CFURLResponseRef);
}
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm (151993 => 151994)
--- trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm 2013-06-26 16:28:49 UTC (rev 151993)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm 2013-06-26 17:03:48 UTC (rev 151994)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -323,4 +323,24 @@
wkSetCFURLResponseMIMEType(cfResponse, result.get());
}
+NSURLResponse *synthesizeRedirectResponseIfNecessary(NSURLConnection *connection, NSURLRequest *newRequest, NSURLResponse *redirectResponse)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ if (redirectResponse)
+ return redirectResponse;
+
+ if ([[[newRequest URL] scheme] isEqualToString:[[[connection currentRequest] URL] scheme]])
+ return nil;
+
+ // If the new request is a different protocol than the current request, synthesize a redirect response.
+ // This is critical for HSTS (<rdar://problem/14241270>).
+ NSDictionary *synthesizedResponseHeaderFields = @{ @"Location": [[newRequest URL] absoluteString], @"Cache-Control": @"no-store" };
+ return [[[NSHTTPURLResponse alloc] initWithURL:[[connection currentRequest] URL] statusCode:302 HTTPVersion:(NSString *)kCFHTTPVersion1_1 headerFields:synthesizedResponseHeaderFields] autorelease];
+#else
+ UNUSED_PARAM(connection);
+ UNUSED_PARAM(newRequest);
+ return redirectResponse;
+#endif
}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes