-
Notifications
You must be signed in to change notification settings - Fork 12
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
Uppercase the http method #112
Conversation
@@ -48,7 +48,7 @@ export class HttpContext { | |||
} | |||
|
|||
const { headers, header, url: rawUrl, method: m } = req.json(); | |||
const method = m ?? 'GET'; | |||
const method = m?.toUpperCase() ?? 'GET'; |
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.
i noticed there are explicit conditional checks for uppercase below. is there somewhere else this could be getting set?
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.
Nope – I think this code used to assume that the pdk will always call with uppercased HTTP verbs.
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.
LGTM!
@@ -48,7 +48,7 @@ export class HttpContext { | |||
} | |||
|
|||
const { headers, header, url: rawUrl, method: m } = req.json(); | |||
const method = m ?? 'GET'; | |||
const method = m?.toUpperCase() ?? 'GET'; |
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.
Huh, TIL ?.
earlier in the chain cascades to the ()
! I would've thought m?.toUpperCase?.()
would be required.
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.
i think it works for methods too? at least i've been doing this in other places. the compiler didn't complain but also i think it's an any
. This does seem to work though:
function z(s?: string | null) {
console.log(s?.toUpperCase() || "GET")
}
z()
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.
becomes:
"use strict";
function z(s) {
console.log((s === null || s === void 0 ? void 0 : s.toUpperCase()) || "GET");
}
z();
Unclear exactly if this is a problem here or if this is the right spot, but had an issue where googleapis.com didn't accept a lowercase http method from the client. gonna make sure the same is in go and rust.