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

Headers should be case insensitive #185

Closed
fappelman opened this issue Mar 30, 2020 · 2 comments · Fixed by #186
Closed

Headers should be case insensitive #185

fappelman opened this issue Mar 30, 2020 · 2 comments · Fixed by #186
Assignees
Labels
bug Something isn't working

Comments

@fappelman
Copy link

I have run into an issue where the library did not follow up on a 301. This was when I accessed the website from wired: https://www.wired.com/story/the-science-of-this-pandemic-is-moving-at-dangerous-speeds

It turns out that this website returns the location header as:

location: https://www.wired.com/story/the-science-of-this-pandemic-is-moving-at-dangerous-speeds/

Note that the location is written as location and not as Location.

In the redirect handler this is managed as:

guard let location = headers.first(where: { $0.name == "Location" }) else {
     return nil
}

According to the RFC: https://ietf.org/rfc/rfc7230.html#section-3.2 the headers are case insensitive. Hence I believe this code should become:

guard let location = headers.first(where: { $0.name.lowercased() == "location" }) else {
     return nil
}

I did not check but I assume there this may be true in other areas as well. The above changed fixed it for me.

I used version 1.1.0 of the package.

@artemredkin artemredkin self-assigned this Mar 30, 2020
@artemredkin artemredkin added the bug Something isn't working label Mar 30, 2020
@artemredkin
Copy link
Collaborator

@fabianfett should be fixed now, tagged 1.1.1

@fappelman
Copy link
Author

Thanks. Appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants