Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: net/http: add constant for content type #31572
"ContentTypeForm" would be a shorter, better name. Should there be a few of the most common ones here?
It would be unfortunate if this leads to more requests to add more, like MethodPost etc have.
This is already an all-too-common mistake and I think that adding the constants would, if anything, make it a little worse.
Before, the issue with code like
was that the left side needed to be parsed to get the media type value out. With
both sides need to be parsed. Or worse, with
it happens to work now, but depends on ContentTypeJSON being a media type value without optional parameters.
Because these constants can only be effectively used for setting the Content-Type and not retrieving it, I don't think we should add them. If we do add API for common Content-Types, I think it ought to be opaque types that can be used for both setting and retrieving.
@bradfitz Have you thought about Content-Type usability? I don't see any references to Content-Type in the discussion around http(client) v2.
I'd like to see a new (string-backed) type for media types. Then we could do:
A nice place for this type might be the
I'd rather not duplicate it with a newer version in