-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwrapper_http_cookies.go
40 lines (32 loc) · 1.02 KB
/
wrapper_http_cookies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package fastshot
import (
"net/http"
)
// DefaultHttpCookies implements CookiesWrapper interface and provides a default HTTP cookies.
var _ CookiesWrapper = (*DefaultHttpCookies)(nil)
// DefaultHttpCookies implements CookiesWrapper interface and provides a default HTTP cookies.
type DefaultHttpCookies struct {
cookies []*http.Cookie
}
// Unwrap will return the underlying cookies
func (c *DefaultHttpCookies) Unwrap() []*http.Cookie {
return c.cookies
}
// Count will return the number of cookies
func (c *DefaultHttpCookies) Count() int {
return len(c.cookies)
}
// Get will return the cookie at the specified index
func (c *DefaultHttpCookies) Get(index int) *http.Cookie {
return c.cookies[index]
}
// Add will append a new cookie to the underlying cookies
func (c *DefaultHttpCookies) Add(cookie *http.Cookie) {
c.cookies = append(c.cookies, cookie)
}
// newDefaultHttpCookies initializes a new DefaultHttpCookies.
func newDefaultHttpCookies() *DefaultHttpCookies {
return &DefaultHttpCookies{
cookies: []*http.Cookie{},
}
}