aboutsummaryrefslogtreecommitdiff
path: root/cookie.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-29 12:15:14 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-29 12:15:14 +0200
commit29b732217a17abe222f72967d49d136765e68007 (patch)
tree4f8bf266d25909f3f3c5815b9ba1d01f7d08f77a /cookie.go
parentAdded missing args.Reset in CopyTo (diff)
downloadfasthttp-29b732217a17abe222f72967d49d136765e68007.tar.gz
fasthttp-29b732217a17abe222f72967d49d136765e68007.tar.bz2
fasthttp-29b732217a17abe222f72967d49d136765e68007.zip
Added CopyTo to Cookie for the sake of API consistency
Diffstat (limited to 'cookie.go')
-rw-r--r--cookie.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cookie.go b/cookie.go
index 63bc588..8849004 100644
--- a/cookie.go
+++ b/cookie.go
@@ -18,6 +18,8 @@ var (
)
// Cookie represents HTTP response cookie.
+//
+// Do not copy Cookie obects. Create new obect and use CopyTo instead.
type Cookie struct {
key []byte
value []byte
@@ -29,6 +31,16 @@ type Cookie struct {
buf []byte
}
+// CopyTo copies src cookie to c.
+func (c *Cookie) CopyTo(src *Cookie) {
+ c.Reset()
+ c.key = append(c.key[:0], src.key...)
+ c.value = append(c.value[:0], src.value...)
+ c.expire = src.expire
+ c.domain = append(c.domain[:0], src.domain...)
+ c.path = append(c.path[:0], src.path...)
+}
+
// Path returns cookie path.
func (c *Cookie) Path() []byte {
return c.path