@@ -476,9 +476,9 @@ internal class _HTTPURLProtocol: _NativeProtocol {
476
476
// We need this ugly cast in order to be able to support `URLSessionTask.init()`
477
477
session. delegateQueue. addOperation {
478
478
delegate. urlSession ( session, task: self . task!, willPerformHTTPRedirection: response as! HTTPURLResponse , newRequest: request) { [ weak self] ( request: URLRequest ? ) in
479
- guard let task = self else { return }
480
- self ? . task? . workQueue. async {
481
- task . didCompleteRedirectCallback ( request)
479
+ guard let self = self else { return }
480
+ self . task? . workQueue. async {
481
+ self . didCompleteRedirectCallback ( request)
482
482
}
483
483
}
484
484
}
@@ -651,7 +651,7 @@ internal extension _HTTPURLProtocol {
651
651
//TODO: Do we ever want to redirect for HEAD requests?
652
652
func methodAndURL( ) -> ( String , URL ) ? {
653
653
guard
654
- let location = response. value ( forHeaderField: . location, response : response ) ,
654
+ let location = response. value ( forHeaderField: . location) ,
655
655
let targetURL = URL ( string: location)
656
656
else {
657
657
// Can't redirect when there's no location to redirect to.
@@ -728,10 +728,9 @@ fileprivate extension HTTPURLResponse {
728
728
case location = " Location "
729
729
}
730
730
731
- func value( forHeaderField field: _Field , response : HTTPURLResponse ? ) -> String ? {
731
+ func value( forHeaderField field: _Field ) -> String ? {
732
732
let value = field. rawValue
733
- guard let response = response else { fatalError ( " Response is nil " ) }
734
- if let location = response. allHeaderFields [ value] as? String {
733
+ if let location = self . allHeaderFields [ value] as? String {
735
734
return location
736
735
}
737
736
return nil
0 commit comments