-
Notifications
You must be signed in to change notification settings - Fork 73
Fetch gateway does not normalize HTTP method casing, leading to request issues with undici #584
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
base: master
Are you sure you want to change the base?
Fetch gateway does not normalize HTTP method casing, leading to request issues with undici #584
Conversation
🦋 Changeset detectedLatest commit: 74bc955 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
klippx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, thanks for the contribution! I think it makes sense, but you need to fix tests too, please 🙏
|
|
||
| const headers = assign(customHeaders, this.request.headers()) | ||
| const method = this.shouldEmulateHTTP() ? 'post' : requestMethod | ||
| const method = this.shouldEmulateHTTP() ? 'POST' : requestMethod.toUpperCase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same should be done in two more files, I know this was originally only for Fetch gateway but the way I see it this is not about your specific case and changing Fetch to be different just because of undici:
src/gateway/http.tssrc/gateway/xhr.ts
| 'mappersmith': patch | ||
| --- | ||
|
|
||
| Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici | |
| Update the `performRequest` method in all gateways to normalize the HTTP method to uppercase. This is to ensure users of mappersmith can continue to use lowercase methods in their manifest and still be compatible with fetch libraries that are equipped with a case sensitive fetch mechanism. |
It appears that the Fetch gateway in Mappersmith does not normalize the HTTP method to uppercase, which can cause issues when using HTTP clients like undici that are case-sensitive about method names.
This is a small fix for an issue related to PATCH requests not working properly producing a 400 Bad Request error.