@@ -145,98 +145,7 @@ public protocol URLProtocolClient : NSObjectProtocol {
145
145
func urlProtocol( _ protocol: URLProtocol , didCancel challenge: URLAuthenticationChallenge )
146
146
}
147
147
148
- internal class _ProtocolClient : NSObject , URLProtocolClient {
149
-
150
- func urlProtocol( _ protocol: URLProtocol , didReceive response: URLResponse , cacheStoragePolicy policy: URLCache . StoragePolicy ) {
151
- `protocol`. task? . response = response
152
- }
153
-
154
- func urlProtocolDidFinishLoading( _ protocol: URLProtocol ) {
155
- guard let task = `protocol`. task else { fatalError ( ) }
156
- guard let session = task. session as? URLSession else { fatalError ( ) }
157
- switch session. behaviour ( for: task) {
158
- case . taskDelegate( let delegate) :
159
- session. delegateQueue. addOperation {
160
- delegate. urlSession ( session, task: task, didCompleteWithError: nil )
161
- task. state = . completed
162
- session. taskRegistry. remove ( task)
163
- }
164
- case . noDelegate:
165
- task. state = . completed
166
- session. taskRegistry. remove ( task)
167
- case . dataCompletionHandler:
168
- let data = Data ( )
169
- guard let client = `protocol`. client else { fatalError ( ) }
170
- client. urlProtocol ( `protocol`, didLoad: data)
171
- return
172
- case . downloadCompletionHandler( let completion) :
173
- session. delegateQueue. addOperation {
174
- completion ( task. currentRequest? . url, task. response, nil )
175
- task. state = . completed
176
- session. taskRegistry. remove ( task)
177
- }
178
- }
179
- }
180
-
181
- func urlProtocol( _ protocol: URLProtocol , didCancel challenge: URLAuthenticationChallenge ) {
182
- NSUnimplemented ( )
183
- }
184
-
185
- func urlProtocol( _ protocol: URLProtocol , didReceive challenge: URLAuthenticationChallenge ) {
186
- NSUnimplemented ( )
187
- }
188
-
189
- func urlProtocol( _ protocol: URLProtocol , didLoad data: Data ) {
190
- guard let task = `protocol`. task else { fatalError ( ) }
191
- guard let session = task. session as? URLSession else { fatalError ( ) }
192
- switch session. behaviour ( for: task) {
193
- case . dataCompletionHandler( let completion) :
194
- guard let s = task. session as? URLSession else { fatalError ( ) }
195
- s. delegateQueue. addOperation {
196
- completion ( data, task. response, nil )
197
- task. state = . completed
198
- s. taskRegistry. remove ( task)
199
- }
200
- default : return
201
- }
202
- }
203
-
204
- func urlProtocol( _ protocol: URLProtocol , didFailWithError error: Error ) {
205
- guard let task = `protocol`. task else { fatalError ( ) }
206
- guard let session = task. session as? URLSession else { fatalError ( ) }
207
- switch session. behaviour ( for: task) {
208
- case . taskDelegate( let delegate) :
209
- session. delegateQueue. addOperation {
210
- delegate. urlSession ( session, task: task, didCompleteWithError: error as Error )
211
- task. state = . completed
212
- session. taskRegistry. remove ( task)
213
- }
214
- case . noDelegate:
215
- task. state = . completed
216
- session. taskRegistry. remove ( task)
217
- case . dataCompletionHandler( let completion) :
218
- session. delegateQueue. addOperation {
219
- completion ( nil , nil , error)
220
- task. state = . completed
221
- session. taskRegistry. remove ( task)
222
- }
223
- case . downloadCompletionHandler( let completion) :
224
- session. delegateQueue. addOperation {
225
- completion ( nil , nil , error)
226
- task. state = . completed
227
- session. taskRegistry. remove ( task)
228
- }
229
- }
230
- }
231
-
232
- func urlProtocol( _ protocol: URLProtocol , cachedResponseIsValid cachedResponse: CachedURLResponse ) {
233
- NSUnimplemented ( )
234
- }
235
-
236
- func urlProtocol( _ protocol: URLProtocol , wasRedirectedTo request: URLRequest , redirectResponse: URLResponse ) {
237
- NSUnimplemented ( )
238
- }
239
- }
148
+ internal class _ProtocolClient : NSObject { }
240
149
241
150
/*!
242
151
@class NSURLProtocol
0 commit comments