@@ -401,8 +401,9 @@ internal class _HTTPURLProtocol: _NativeProtocol {
401
401
easyHandle. timeoutTimer = _TimeoutSource ( queue: task. workQueue, milliseconds: timeoutInterval, handler: timeoutHandler)
402
402
easyHandle. set ( automaticBodyDecompression: true )
403
403
easyHandle. set ( requestMethod: request. httpMethod ?? " GET " )
404
- // Always set the status as it may change if a HEAD is converted to a GET.
405
- easyHandle. set ( noBody: request. httpMethod == " HEAD " )
404
+ if request. httpMethod == " HEAD " {
405
+ easyHandle. set ( noBody: true )
406
+ }
406
407
}
407
408
408
409
/// What action to take
@@ -590,7 +591,7 @@ internal extension _HTTPURLProtocol {
590
591
// For now, we'll notify the delegate, but won't pause the transfer,
591
592
// and we'll disregard the completion handler:
592
593
switch response. statusCode {
593
- case 301 , 302 , 303 , 305 ... 308 :
594
+ case 301 , 302 , 303 , 307 :
594
595
break
595
596
default :
596
597
self . client? . urlProtocol ( self , didReceive: response, cacheStoragePolicy: . notAllowed)
@@ -618,26 +619,19 @@ internal extension _HTTPURLProtocol {
618
619
return nil
619
620
}
620
621
621
- let method = fromRequest. httpMethod ?? " GET "
622
622
// Check for a redirect:
623
623
switch response. statusCode {
624
- case 301 , 302 :
625
- // Change "POST" into "GET" but leave other methods unchanged:
626
- let newMethod = ( method == " POST " ) ? " GET " : method
627
- return ( newMethod, targetURL)
628
-
629
- case 303 :
630
- return ( " GET " , targetURL)
631
-
632
- case 305 ... 308 :
633
- // Re-use existing method:
634
- return ( method, targetURL)
635
-
636
- default :
637
- return nil
624
+ //TODO: Should we do this for 300 "Multiple Choices", too?
625
+ case 301 , 302 , 303 :
626
+ // Change into "GET":
627
+ return ( " GET " , targetURL)
628
+ case 307 :
629
+ // Re-use existing method:
630
+ return ( fromRequest. httpMethod ?? " GET " , targetURL)
631
+ default :
632
+ return nil
638
633
}
639
634
}
640
-
641
635
guard let ( method, targetURL) = methodAndURL ( ) else { return nil }
642
636
var request = fromRequest
643
637
request. httpMethod = method
0 commit comments