diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-05 12:54:10 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-05 12:54:10 +0200 |
commit | 236d4bd461ed086e433e76f11f8af331578701b2 (patch) | |
tree | bc6779625cdec7c05c5bd798e95530faa410b45d /cookie.go | |
parent | Increased cookies' parsing performance (diff) | |
download | fasthttp-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.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 |