Fix the build with newer clang and other custom configuration options
[WebKit-https.git] / Source / WebCore / platform / spi / cf / CFNetworkSPI.h
1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #pragma clang system_header
27
28 #ifndef CFNetworkSPI_h
29 #define CFNetworkSPI_h
30
31 #include "CFNetworkConnectionCacheSPI.h"
32 #include <CFNetwork/CFNetwork.h>
33
34 #if PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
35
36 #include <CFNetwork/CFHTTPCookiesPriv.h>
37 #include <CFNetwork/CFProxySupportPriv.h>
38 #include <CFNetwork/CFURLCachePriv.h>
39 #include <CFNetwork/CFURLConnectionPriv.h>
40 #include <CFNetwork/CFURLCredentialStorage.h>
41 #include <CFNetwork/CFURLProtocolPriv.h>
42 #include <CFNetwork/CFURLRequestPriv.h>
43 #include <CFNetwork/CFURLResponsePriv.h>
44 #include <CFNetwork/CFURLStorageSession.h>
45
46 // FIXME: Remove the defined(__OBJC__)-guard once we fix <rdar://problem/19033610>.
47 #if defined(__OBJC__) && PLATFORM(COCOA)
48 // FIXME: As a workaround for <rdar://problem/18337182>, we conditionally enclose the header
49 // in an extern "C" linkage block to make it suitable for C++ use.
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 #import <CFNetwork/CFNSURLConnection.h>
55
56 #ifdef __cplusplus
57 }
58 #endif
59 #endif // defined(__OBJC__) && PLATFORM(COCOA)
60
61 #else // !PLATFORM(WIN) && !USE(APPLE_INTERNAL_SDK)
62
63 typedef CF_ENUM(int64_t, _TimingDataOptions)
64 {
65     _TimingDataOptionsEnableW3CNavigationTiming = (1 << 0)
66 };
67
68 typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
69 typedef const struct _CFURLCache* CFURLCacheRef;
70 typedef const struct _CFURLCredential* CFURLCredentialRef;
71 typedef const struct _CFURLRequest* CFURLRequestRef;
72 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
73 typedef const struct __CFData* CFDataRef;
74 typedef const struct OpaqueCFHTTPCookie* CFHTTPCookieRef;
75 typedef struct _CFURLConnection* CFURLConnectionRef;
76 typedef struct _CFURLCredentialStorage* CFURLCredentialStorageRef;
77 typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
78 typedef struct _CFURLRequest* CFMutableURLRequestRef;
79 typedef struct _CFURLResponse* CFURLResponseRef;
80 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
81 typedef CFIndex CFURLRequestPriority;
82 typedef int CFHTTPCookieStorageAcceptPolicy;
83
84 #ifdef __BLOCKS__
85 typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
86 #endif
87
88 #if defined(__OBJC__)
89 @interface NSURLRequest ()
90 + (NSArray *)allowsSpecificHTTPSCertificateForHost:(NSString *)host;
91 + (void)setAllowsSpecificHTTPSCertificate:(NSArray *)allow forHost:(NSString *)host;
92 - (void)_setProperty:(id)value forKey:(NSString *)key;
93 @end
94
95 @interface NSURLResponse ()
96 + (NSURLResponse *)_responseWithCFURLResponse:(CFURLResponseRef)response;
97 - (CFURLResponseRef)_CFURLResponse;
98 - (NSDate *)_lastModifiedDate;
99 @end
100
101 @interface NSURLSessionTask (TimingData)
102 - (NSDictionary *)_timingData;
103 @end
104
105 @interface NSHTTPCookie ()
106 - (CFHTTPCookieRef)_CFHTTPCookie;
107 @end
108
109 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000)
110 @interface NSURLSessionConfiguration ()
111 @property (assign) _TimingDataOptions _timingDataOptions;
112 @property (copy) NSData *_sourceApplicationAuditTokenData;
113 @property (copy) NSString *_sourceApplicationBundleIdentifier;
114 @end
115 #endif
116
117 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
118 @interface NSHTTPCookie ()
119 @property (nullable, readonly, copy) NSString *_storagePartition;
120 @end
121
122 @interface NSHTTPCookieStorage ()
123 - (void)_getCookiesForURL:(NSURL *)url mainDocumentURL:(NSURL *)mainDocumentURL partition:(NSString *)partition completionHandler:(void (^)(NSArray *))completionHandler;
124 @end
125
126 @interface NSURLSessionTask ()
127 @property (readwrite, copy) NSString *_pathToDownloadTaskFile;
128 @property (copy) NSString *_storagePartitionIdentifier;
129 @end
130 #endif
131
132 #endif // defined(__OBJC__)
133
134 #endif // !PLATFORM(WIN) && !USE(APPLE_INTERNAL_SDK)
135
136 EXTERN_C void CFURLRequestSetShouldStartSynchronously(CFURLRequestRef, Boolean);
137
138 EXTERN_C CFURLCacheRef CFURLCacheCopySharedURLCache();
139 EXTERN_C void CFURLCacheSetMemoryCapacity(CFURLCacheRef, CFIndex memoryCapacity);
140 #if PLATFORM(COCOA)
141 EXTERN_C Boolean _CFNetworkIsKnownHSTSHostWithSession(CFURLRef, CFURLStorageSessionRef);
142 EXTERN_C void _CFNetworkResetHSTSHostsWithSession(CFURLStorageSessionRef);
143 #endif
144
145 EXTERN_C void CFHTTPCookieStorageDeleteAllCookies(CFHTTPCookieStorageRef);
146
147 #if PLATFORM(COCOA)
148 EXTERN_C CFDataRef _CFCachedURLResponseGetMemMappedData(CFCachedURLResponseRef);
149 #ifdef __BLOCKS__
150 EXTERN_C void _CFCachedURLResponseSetBecameFileBackedCallBackBlock(CFCachedURLResponseRef, CFCachedURLResponseCallBackBlock, dispatch_queue_t);
151 #endif
152 #endif // PLATFORM(COCOA)
153
154 EXTERN_C void CFURLConnectionInvalidateConnectionCache();
155
156 EXTERN_C CFStringRef const kCFHTTPCookieLocalFileDomain;
157 EXTERN_C const CFStringRef kCFURLRequestAllowAllPOSTCaching;
158
159 #if !PLATFORM(WIN)
160 EXTERN_C const CFStringRef _kCFURLConnectionPropertyShouldSniff;
161 #endif
162
163 EXTERN_C CFHTTPCookieStorageRef _CFHTTPCookieStorageGetDefault(CFAllocatorRef);
164 EXTERN_C void CFHTTPCookieStorageSetCookie(CFHTTPCookieStorageRef, CFHTTPCookieRef);
165 EXTERN_C void CFHTTPCookieStorageSetCookieAcceptPolicy(CFHTTPCookieStorageRef, CFHTTPCookieStorageAcceptPolicy);
166 EXTERN_C void _CFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
167 EXTERN_C CFURLCredentialStorageRef CFURLCredentialStorageCreate(CFAllocatorRef);
168 EXTERN_C CFURLCredentialRef CFURLCredentialStorageCopyDefaultCredentialForProtectionSpace(CFURLCredentialStorageRef, CFURLProtectionSpaceRef);
169 EXTERN_C CFURLRequestPriority CFURLRequestGetRequestPriority(CFURLRequestRef);
170 EXTERN_C void _CFURLRequestSetProtocolProperty(CFURLRequestRef, CFStringRef, CFTypeRef);
171 EXTERN_C void CFURLRequestSetRequestPriority(CFURLRequestRef, CFURLRequestPriority);
172 EXTERN_C void CFURLRequestSetShouldPipelineHTTP(CFURLRequestRef, Boolean, Boolean);
173 EXTERN_C void _CFURLRequestSetStorageSession(CFMutableURLRequestRef, CFURLStorageSessionRef);
174 EXTERN_C CFStringRef CFURLResponseCopySuggestedFilename(CFURLResponseRef);
175 EXTERN_C CFHTTPMessageRef CFURLResponseGetHTTPResponse(CFURLResponseRef);
176 EXTERN_C CFStringRef CFURLResponseGetMIMEType(CFURLResponseRef);
177 EXTERN_C CFDictionaryRef _CFURLResponseGetSSLCertificateContext(CFURLResponseRef);
178 EXTERN_C CFURLRef CFURLResponseGetURL(CFURLResponseRef);
179 EXTERN_C void CFURLResponseSetMIMEType(CFURLResponseRef, CFStringRef);
180 EXTERN_C CFHTTPCookieStorageRef _CFURLStorageSessionCopyCookieStorage(CFAllocatorRef, CFURLStorageSessionRef);
181
182 // FIXME: We should only forward declare this SPI when building for iOS without the Apple Internal SDK.
183 // As a workaround for <rdar://problem/19025016>, we must forward declare this SPI regardless of whether
184 // we are building with the Apple Internal SDK.
185 #if defined(__OBJC__) && PLATFORM(IOS)
186 @interface NSURLCache ()
187 -(id)_initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity relativePath:(NSString *)path;
188 @end
189 #endif
190
191 #if defined(__OBJC__) && !USE(APPLE_INTERNAL_SDK)
192 enum : NSUInteger {
193     NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3,
194 };
195
196 @interface NSCachedURLResponse ()
197 -(id)_initWithCFCachedURLResponse:(CFCachedURLResponseRef)cachedResponse;
198 -(CFCachedURLResponseRef)_CFCachedURLResponse;
199 @end
200 #endif
201
202 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
203 EXTERN_C CFDataRef _CFNetworkCopyATSContext(void);
204 EXTERN_C Boolean _CFNetworkSetATSContext(CFDataRef);
205 #endif
206
207 #if PLATFORM(COCOA)
208 EXTERN_C void _CFNetworkResetHSTSHostsSinceDate(CFURLStorageSessionRef, CFDateRef);
209 #endif
210
211 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
212 EXTERN_C CFDataRef CFHTTPCookieStorageCreateIdentifyingData(CFAllocatorRef inAllocator, CFHTTPCookieStorageRef inStorage);
213 EXTERN_C CFHTTPCookieStorageRef CFHTTPCookieStorageCreateFromIdentifyingData(CFAllocatorRef inAllocator, CFDataRef inData);
214 EXTERN_C CFArrayRef _CFHTTPParsedCookiesWithResponseHeaderFields(CFAllocatorRef inAllocator, CFDictionaryRef headerFields, CFURLRef inURL);
215 #endif
216
217 #if defined(__OBJC__)
218
219 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
220 @interface NSHTTPCookie ()
221 + (NSArray *)_parsedCookiesWithResponseHeaderFields:(NSDictionary *)headerFields forURL:(NSURL *)aURL;
222 @end
223 #endif
224
225 #if !USE(APPLE_INTERNAL_SDK)
226 @interface NSHTTPCookieStorage ()
227 - (void)removeCookiesSinceDate:(NSDate *)date;
228 - (id)_initWithCFHTTPCookieStorage:(CFHTTPCookieStorageRef)cfStorage;
229 - (CFHTTPCookieStorageRef)_cookieStorage;
230 - (void)_saveCookies;
231 @end
232 #endif
233
234 // FIXME: Move +_setSharedHTTPCookieStorage: into the above section under !USE(APPLE_INTERNAL_SDK) when possible (soon).
235 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
236 @interface NSHTTPCookieStorage ()
237 + (void)_setSharedHTTPCookieStorage:(NSHTTPCookieStorage *)storage;
238 @end
239 #endif
240 #endif // defined(__OBJC__)
241
242 #endif // CFNetworkSPI_h