Skip to content

net/http: support cookie values with comma #7243

@shanemhansen

Description

@shanemhansen
Go has a RFC 6265 compliant cookie parser in net/http that is used for the builtin http
server. Which means commas aren't allowed in cookie values (what the rfc specified in
the BNF as "cookie-octet").

Despite not being RFC compliant, all browsers that I'm aware of allow commas. When
replatforming an existing system to Golang, I'm unable to read in cookies set by the
another server (nginx) or set cookies in a way that mimics the legacy app.

I'd like to see net/http/cookie.go do less validation on cookie values so that it
matches the behavior of firefox and chrome, because this will make it easier to replace
legacy systems with Go.

I can produce a patch. The relevant lines of code in the go parser are:
http://golang.org/src/pkg/net/http/cookie.go#L308
http://golang.org/src/pkg/net/http/cookie.go#L350


Existing browser implementations:
http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp#3095

http://src.chromium.org/viewvc/chrome/trunk/src/net/cookies/parsed_cookie.cc#l143

Which compiler are you using (5g, 6g, 8g, gccgo)?
Affects all compilers

Which operating system are you using?
Affects all OS's

Which version are you using?  (run 'go version')
go 1.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions