Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/net: net/http: Export function to parse http comma separated list header #44417

Open
shaj13 opened this issue Feb 19, 2021 · 2 comments
Open
Labels
Projects
Milestone

Comments

@shaj13
Copy link

@shaj13 shaj13 commented Feb 19, 2021

What did you expect to see?

Essentially, I'd like golang.org/x/net or net/http to expose functions to parse an HTTP comma-separated list header.
e.g Cache-Control and WWW-Authenticate

Note:
Content-Type and Content-Disposition can be parsed using mime

Currently, most of the go developers use alternatives like the archived gddo/httputil/header/.

net/http already expose ParseTime that exist in gddo/httputil/header/.

So I'd like to copy the underlying gddo/httputil/header/ implementation into x/net/http/httpguts
and change the method signatures to be as net/http ParseTime.

// ParseList parses a comma separated list of values. Commas are ignored in
// quoted strings. Quoted values are not unescaped or unquoted. Whitespace is
// trimmed.
func ParseList(header string) []string {}

// ParsePairs extracts key/value pairs from a comma-separated list of
// values as described by RFC 2068 and returns a map[key]value
func ParsePairs(header string) map[string]string {}

Example:
https://play.golang.org/p/LrsYjRqUJzP

@gopherbot gopherbot added this to the Proposal milestone Feb 19, 2021
@shaj13 shaj13 changed the title proposal: Export function to parse http comma separated list header proposal: x/net: net/http: Export function to parse http comma separated list header Feb 19, 2021
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Feb 19, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 19, 2021

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 19, 2021

#41046 would be a more general solution, and maybe it should be moved off hold now that it's an RFC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Proposals
Incoming
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants