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

[SR-12135] Linux: Data.init(contentsOf: URL) does not account for failed http response codes. #4478

Closed
swift-ci opened this issue Feb 6, 2020 · 2 comments
Assignees

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Feb 6, 2020

Previous ID SR-12135
Radar rdar://problem/59216639
Original Reporter kuwerty (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @spevans
Priority Medium

md5: 03d8ad5d55e56dd90fabb52c02670331

Issue Description:

On Linux (tested with swift 5.1.4) the following (just at the lldb prompt will do) returns a valid chunk of data with no exception thrown. The data, if converted to a string, is Apple's 404 page.

(lldb) p Data(contentsOf:URL(string:"https://www.apple.com/a404/")!)

(Data) $R14 = 35006 bytes

On MacOS the same thing throws an exception.

I think (and I'm looking at _NSNonfileURLContentLoader) that it's just not inspecting the http response status codes. Given that there's no way for my app to know it's a 404 by inspecting the returned Data object this is incorrect behaviour.

For completeness curl confirms it's a 404 🙂

$ curl https://www.apple.com/a404/ -vvvv

...snip..

  • Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
    < HTTP/2 404
    < server: Apache
    < x-frame-options: SAMEORIGIN
    < x-xss-protection: 1; mode=block
    < x-content-type-options: nosniff
    <
@beccadax
Copy link
Contributor

beccadax commented Feb 6, 2020

@swift-ci create

@spevans
Copy link
Collaborator

spevans commented Mar 23, 2020

#2742

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants