Skip to content

fix: patch requests are case-sensitive#66

Merged
developit merged 4 commits intodevelopit:masterfrom
semoal:fix-patch-req
Apr 29, 2022
Merged

fix: patch requests are case-sensitive#66
developit merged 4 commits intodevelopit:masterfrom
semoal:fix-patch-req

Conversation

@semoal
Copy link
Copy Markdown

@semoal semoal commented Apr 16, 2021

I've added a test to avoid a regression on this :)
Here it is @developit ;)

@semoal semoal mentioned this pull request Apr 16, 2021
@semoal
Copy link
Copy Markdown
Author

semoal commented Apr 25, 2021

@developit Ping on this Jason, don't want to add hurry just pinging to not forget =)

@lkmill
Copy link
Copy Markdown

lkmill commented Apr 30, 2021

any reason you are not uppercasing all http methods? even if they dont seem to break when lowercase i reckon they should be converted to uppercase both for consistency but more importantly the spec seems to recommend normalizing (converting to uppercase) all methods for backwards compatibility:

https://fetch.spec.whatwg.org/#methods

@semoal
Copy link
Copy Markdown
Author

semoal commented May 1, 2021

any reason you are not uppercasing all http methods? even if they dont seem to break when lowercase i reckon they should be converted to uppercase both for consistency but more importantly the spec seems to recommend normalizing (converting to uppercase) all methods for backwards compatibility:

https://fetch.spec.whatwg.org/#methods

Didn't know that ;) just fixing the wrong use case, but if normalizing is the correct approach I'll modify the PR later, thanks mate

@sirlancelot
Copy link
Copy Markdown
Contributor

sirlancelot commented Aug 5, 2021

In Google Chrome, patch specifically seemed to be causing problems. I'd been Googling for about an hour and finally came across this SO post: https://stackoverflow.com/a/67744766/51021

Apparently, some verbs (PATCH in my case) ARE case-sensitive when comparing against a pre-flight OPTIONS check.

I think in order to be the most compatible with the axios module, and to make PATCH work during cross-origin requests, these verbs should be made uppercase (See axios source: axios/lib/adapters/xhr.js#L32)

@googlebot
Copy link
Copy Markdown
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@developit
Copy link
Copy Markdown
Owner

From the size bot:

Size Change: +56 B (1%)

Total Size: 3.02 kB

Filename Size Change
dist/redaxios.js 990 B +18 B (1%)
dist/redaxios.module.js 990 B +19 B (1%)
dist/redaxios.umd.js 1.04 kB +19 B (1%)

compressed-size-action

@developit
Copy link
Copy Markdown
Owner

I might try checking if 'get'.toUpperCase() produces smaller sizes when minified.

@semoal semoal force-pushed the fix-patch-req branch 2 times, most recently from 774d095 to fddb4da Compare November 7, 2021 22:24
@semoal
Copy link
Copy Markdown
Author

semoal commented Nov 7, 2021

@googlebot I fixed it.

@semoal
Copy link
Copy Markdown
Author

semoal commented Nov 7, 2021

I might try checking if 'get'.toUpperCase() produces smaller sizes when minified.

Yep, I think so.

With uppercase:

Build "redaxios" to dist:
        949 B: redaxios.js.gz
        825 B: redaxios.js.br
        945 B: redaxios.module.js.gz
        823 B: redaxios.module.js.br
        997 B: redaxios.umd.js.gz
        871 B: redaxios.umd.js.br

Without uppercase

Build "redaxios" to dist:
        962 B: redaxios.js.gz
        821 B: redaxios.js.br
        958 B: redaxios.module.js.gz
        816 B: redaxios.module.js.br
       1009 B: redaxios.umd.js.gz
        868 B: redaxios.umd.js.br

Just pushed the change to test against the github workflow.

@matschik
Copy link
Copy Markdown

We just encountered the same problem and this PR would fix it 🥳
Is there anything blocking the merge ?

@developit developit linked an issue Apr 29, 2022 that may be closed by this pull request
@developit
Copy link
Copy Markdown
Owner

Size Change: +34 B (1%)

Total Size: 2.99 kB

Filename Size Change
dist/redaxios.js 982 B +10 B (1%)
dist/redaxios.module.js 983 B +12 B (1%)
dist/redaxios.umd.js 1.03 kB +12 B (1%)

@developit developit merged commit cde69c5 into developit:master Apr 29, 2022
@semoal semoal deleted the fix-patch-req branch May 1, 2022 17:21
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

Successfully merging this pull request may close these issues.

lower case method?

6 participants