-
Notifications
You must be signed in to change notification settings - Fork 630
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
http: Cookie extend #359
http: Cookie extend #359
Conversation
http/cookie.ts
Outdated
@@ -19,3 +106,33 @@ export function getCookie(rq: ServerRequest): Cookie { | |||
} | |||
return {}; | |||
} | |||
|
|||
/* Set the cookie header properly in the Response */ |
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.
Use jsdoc style comments.
Regarding the naming of the functions |
About the name consistency for the For Finally for |
http/cookie.ts
Outdated
|
||
export type SameSite = "Strict" | "Lax"; | ||
|
||
export function cookieDateFormat(date: Date): string { |
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.
Is this a specific date format for cookies? Does it have a name? If it's not just for cookies, consider moving this to //datetime
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 was thinking it was specific but no. It's called IMF-fixdate
. I'll move it to datetime. Also is date.toIMF()
good naming for you?
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.
Is there a name for this in Go? Perhaps you can borrow that.
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.
No, the only mention of it i can find is IMF-fixdate
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 you can call it "RFC1123_GMT"
We don't have the same way of serializing datetime formats as Go. I'd like to slowly move in that direction tho. So I think you can just keep the toIMF()
where it is now. But please familiarize yourself with how I think this would be ideally structured:
https://github.com/golang/go/blob/f67f5511ee0f225bcc8943994ba6139eed375e85/src/net/http/server.go#L903-L909
https://github.com/golang/go/blob/f67f5511ee0f225bcc8943994ba6139eed375e85/src/net/http/cookie.go#L200-L204
Consider adding some of the commentary from Go to the jsdoc of "toIMF()"
Go doesn't have a corresponding function to |
@ry about the go Implementation, it's not really common about the manipulation of the Just about the |
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 - nice work
Correct me if I'm wrong for the following codes: In the case of splitting the cookie value with The expected output should be {
PREF: 'al=en-GB&f1=123',
wide: '1',
SID: '123'
} instead of {
PREF: alen-GB&f1123,
wide: '1',
SID: '123'
} |
Right, fair analysis. Should be |
Add
delCookie
andsetCookie
.I have a concern about the multiple
Set-Cookie
header. It's common to use BUTHeaders
does not give us the possibility to do this. Do you think any workaround is possible? I think we can keep it like this for the moment and work on multipleSet-Cookie
headers handling in a future PR.Also Days / Months format are hardcoded in the module because ATM there is some discussions about embedding or not the ICU in Deno which may break this module. Ref: denoland/deno#1968