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

Request header unexpectedly mutated #12

Open
eappel opened this issue May 11, 2022 · 4 comments
Open

Request header unexpectedly mutated #12

eappel opened this issue May 11, 2022 · 4 comments

Comments

@eappel
Copy link

eappel commented May 11, 2022

In this example, I'm supplying an uppercased request header but it's getting lowercased somewhere within the parsing library. I couldn't easily figure out where this was happening to fix with a PR so opening as an issue!

enum TestRoute {
    case testing(value: String)
}

let testingRouter = Route(.case(TestRoute.testing)) {
    Path {
        "testing"
    }
    Headers {
        Field("UPPERCASED-HEADER")
    }
}

func test() async throws {
    let request = try testingRouter.request(
        for: TestRoute.testing(value: "VALUE")
    )
    print(request.allHTTPHeaderFields!)
}

printed:
["uppercased-header": "VALUE"]

expected:
["UPPERCASED-HEADER": "VALUE"]

@stephencelis
Copy link
Member

@eappel HTTP header names are case insensitive, so the library currently lowercases things for consistency. Have you encountered an issue in the wild where this is a problem?

@eappel
Copy link
Author

eappel commented May 11, 2022

Yeah the API I'm dealing with is case-sensitive 😞

I definitely agree that it shouldn't matter though so I'll file a ticket on the backend 👍

@eappel eappel closed this as completed May 11, 2022
@stephencelis
Copy link
Member

@eappel I think we should probably change this behavior on our end, too!

@stephencelis stephencelis reopened this May 11, 2022
@stephencelis
Copy link
Member

@eappel We have an idea that should make it easy to fix this in the future, but we haven't quite finalized the tools yet. We'll leave the issue open for now, but will hopefully get to close it in the next month or two!

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

No branches or pull requests

2 participants