mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-09 22:18:48 +08:00
Merge 929794596f18ada3ca5edfeae193c3b1a1c33823 into 81dba468722f41347ed74ee66e9c1781d72f68a5
This commit is contained in:
commit
b55d988bc7
@ -1111,7 +1111,7 @@ func (c *Context) SetCookie(name, value string, maxAge int, path, domain string,
|
||||
}
|
||||
http.SetCookie(c.Writer, &http.Cookie{
|
||||
Name: name,
|
||||
Value: url.QueryEscape(value),
|
||||
Value: value,
|
||||
MaxAge: maxAge,
|
||||
Path: path,
|
||||
Domain: domain,
|
||||
|
||||
@ -1019,6 +1019,13 @@ func TestContextSetCookiePathEmpty(t *testing.T) {
|
||||
assert.Equal(t, "user=gin; Path=/; Domain=localhost; Max-Age=1; HttpOnly; Secure; SameSite=Lax", c.Writer.Header().Get("Set-Cookie"))
|
||||
}
|
||||
|
||||
func TestContextSetCookieWithSpace(t *testing.T) {
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.SetSameSite(http.SameSiteLaxMode)
|
||||
c.SetCookie("user", "gin test", 1, "/", "localhost", true, true)
|
||||
assert.Equal(t, "user=\"gin test\"; Path=/; Domain=localhost; Max-Age=1; HttpOnly; Secure; SameSite=Lax", c.Writer.Header().Get("Set-Cookie"))
|
||||
}
|
||||
|
||||
func TestContextGetCookie(t *testing.T) {
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest(http.MethodGet, "/get", nil)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user