Skip to content

Commit 92b3bfa

Browse files
authored
Merge pull request #2971 from spevans/pr_urlsession_fix2
URLSession: Update maximum redirects allowed from 16 to 20 to match macOS 11
2 parents 8034671 + 0944e78 commit 92b3bfa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/FoundationNetworking/URLSession/HTTP/HTTPURLProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ internal class _HTTPURLProtocol: _NativeProtocol {
448448
// Avoid a never ending redirect chain by having a hard limit on the number of redirects.
449449
// This value mirrors Darwin.
450450
redirectCount += 1
451-
if redirectCount > 16 {
451+
if redirectCount > 20 {
452452
self.internalState = .transferFailed
453453
let error = NSError(domain: NSURLErrorDomain, code: NSURLErrorHTTPTooManyRedirects,
454454
userInfo: [NSLocalizedDescriptionKey: "too many HTTP redirects"])

Tests/Foundation/Tests/TestURLSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ class TestURLSession: LoopbackServerTest {
829829
}
830830

831831
func test_httpRedirectionExceededMaxRedirects() throws {
832-
let expectedMaxRedirects = 16
832+
let expectedMaxRedirects = 20
833833
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/redirect/99"
834834
let url = try XCTUnwrap(URL(string: urlString))
835835
let exceededCountUrlString = "http://127.0.0.1:\(TestURLSession.serverPort)/redirect/\(99 - expectedMaxRedirects)"

0 commit comments

Comments
 (0)