Ejemplo n.º 1
0
func CookieTest(t *testing.T, cookie engine.Cookie) {
	assert.Equal(t, "github.com", cookie.Domain())
	assert.Equal(t, time.Date(2016, time.January, 1, 0, 0, 0, 0, time.UTC), cookie.Expires())
	assert.True(t, cookie.HTTPOnly())
	assert.True(t, cookie.Secure())
	assert.Equal(t, "session", cookie.Name())
	assert.Equal(t, "/", cookie.Path())
	assert.Equal(t, "securetoken", cookie.Value())
}
Ejemplo n.º 2
0
// SetCookie implements `engine.Response#SetCookie` function.
func (r *Response) SetCookie(c engine.Cookie) {
	http.SetCookie(r.response, &http.Cookie{
		Name:     c.Name(),
		Value:    c.Value(),
		Path:     c.Path(),
		Domain:   c.Domain(),
		Expires:  c.Expires(),
		Secure:   c.Secure(),
		HttpOnly: c.HTTPOnly(),
	})
}
Ejemplo n.º 3
0
// SetCookie implements `engine.Response#SetCookie` function.
func (r *Response) SetCookie(c engine.Cookie) {
	cookie := new(fasthttp.Cookie)
	cookie.SetKey(c.Name())
	cookie.SetValue(c.Value())
	cookie.SetPath(c.Path())
	cookie.SetDomain(c.Domain())
	cookie.SetExpire(c.Expires())
	cookie.SetSecure(c.Secure())
	cookie.SetHTTPOnly(c.HTTPOnly())
	r.Response.Header.SetCookie(cookie)
}