Ask questionsImprovement request: Normalize certain HTTP methods to upper-case?

I dropped this module into some existing boilerplate using the fetch API and it mostly worked except for one hitch: passing {method: 'get'} as the HTTP method results in an invalid signature as the string to compare needs the upper-case GET.

I believe the Fetch API standard is case-sensitive (so you could pass an HTTP method like WhatEver with mixed-case) however typically the methods get, post, delete, etc., are normalized to uppercase. So typically passing the HTTP method lower-case as get just works.

I can find examples online where the browser fetch API is invoked using get in lower-case. But, yes, a bad habit.

I opened this issue to discuss normalizing the common methods like GET, PUT, POST, PATCH, OPTIONS, DELETE if a user of the library provides them lower-case (e.g. get) so that the string-to-sign will be uppercase as needed.

The error does not surface in Chrome DevTools as anything sensible and instead complains about CORS in the console. I had to 1) navigate to Network tools to see that the response included an error header (x-amzn-errortype: InvalidSignatureException) and then 2) replay the request in cURL to see the actual signature error JSON in the response.


Answer questions mhart

Sorry, forgot to comment here, but I fixed this back in 1.0.4 – thanks for reporting!


Related questions

No questions were found.
Github User Rank List