swift-url-routing
swift-url-routing copied to clipboard
Request header unexpectedly mutated
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"]
@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?
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 I think we should probably change this behavior on our end, too!
@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!