Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

39391319: Race condition with custom NSURLProtocol ignores HTTP 3xx redirects #19634

Open
openradar-mirror opened this issue Apr 12, 2018 · 0 comments

Comments

@openradar-mirror
Copy link

Description

Area:
Foundation

Summary:
When using a custom NSURLProtocol subclass to intercept HTTP requests, NSURLSession sometimes ignores 302 redirects and instead returns the 302 response or no response whatsoever. No error is returned.

If the NSURLSessionTaskDelegate artificially introduces a delay in URLSession: task: willPerformHTTPRedirection: ..., the bug is no longer reproducible.

Steps to Reproduce:
Run the unit tests in the attached sample project. On average, the redirection without delay fails 1-2 times per test run. The redirection with a delay introduced by usleep(500) has not yet failed.

If you do not observe any test failures on the first run, please try once or twice more. If you observe the delayed tests failing, please try increasing the usleep parameter.

Expected Results:
NSURLSession should always follow 302 redirects and return the contents of the final URL, or else it should return an error.

Actual Results:
Randomly, the 302 is not followed and instead the body of the original response is returned. No error is returned.

Version/Build:
macOS 10.13.4 (17E199)

The issue has been known and reproducible since August 2016 as seen in this OHHTTPStubs bug report:
AliSoftware/OHHTTPStubs#230

Product Version: 10.13.4
Created: 2018-04-12T20:17:57.172350
Originated: 2018-04-12T00:00:00
Open Radar Link: http://www.openradar.me/39391319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant