aboutsummaryrefslogtreecommitdiff
path: root/cookie.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-05 12:54:10 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-11-05 12:54:10 +0200
commit236d4bd461ed086e433e76f11f8af331578701b2 (patch)
treebc6779625cdec7c05c5bd798e95530faa410b45d /cookie.go
parentIncreased cookies' parsing performance (diff)
downloadfasthttp-236d4bd461ed086e433e76f11f8af331578701b2.tar.gz
fasthttp-236d4bd461ed086e433e76f11f8af331578701b2.tar.bz2
fasthttp-236d4bd461ed086e433e76f11f8af331578701b2.zip
Added Cookie.ParseBytes to be consistent with Args
Diffstat (limited to 'cookie.go')
-rw-r--r--cookie.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cookie.go b/cookie.go
index e202628..16643f4 100644
--- a/cookie.go
+++ b/cookie.go
@@ -36,6 +36,7 @@ type Cookie struct {
Path []byte
bufKV argsKV
+ buf []byte
}
var zeroTime time.Time
@@ -77,7 +78,15 @@ func (c *Cookie) AppendBytes(dst []byte) []byte {
var errNoCookies = errors.New("no cookies found")
// Parse parses Set-Cookie header.
-func (c *Cookie) Parse(src []byte) error {
+func (c *Cookie) Parse(src string) error {
+ c.buf = AppendBytesStr(c.buf[:0], src)
+ return c.ParseBytes(c.buf)
+}
+
+// ParseBytes parses Set-Cookie header.
+//
+// It is safe modifying src buffer after function return.
+func (c *Cookie) ParseBytes(src []byte) error {
c.Clear()
var s cookieScanner