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
net/http: support multipart/mixed in Request.MultipartReader() #23959
Comments
Why? The motivation for https://golang.org/pkg/net/http/#Request.MultipartReader was so you could get file uploads from browsers easily. What uses multipart/mixed? And what's wrong with your "good" handler? That seems fine to me. That is, our underlying https://golang.org/pkg/mime/multipart/#Reader already supports what you want. You just don't like the convenience wrapper, but it's not clear why it's convenient. It's also not clear that this is safe to do. Isn't multipart/mixed used when people are sending "alternatives"? I'd be a little concerned that code that previously was unprepared for such forms would now blindly accept it, without considering which alternative they want. I'd prefer people to "opt-in" to the expanded set of allowed inputs by calling the underlying Reader constructor themselves. |
@bradfitz my current use case is uploading a file + json metadata in one request rather than:
multipart/mixed is pretty much the same as multipart/form-data except each "part" can have different headers / content-type and it's generally used in SMTP, however few APIs use it here and there. https://golang.org/pkg/net/http/#Request.MultipartReader already supports multipart/form-data, the underlying https://golang.org/pkg/mime/multipart/#Reader supports multipart/* in general. edit you were thinking about |
Sure, we can accept |
Change https://golang.org/cl/95975 mentions this issue: |
What did you do?
Ran https://play.golang.org/p/uW3bq_3Z6Ym then in the terminal:
What did you expect to see?
No errors from
req.MultipartReader()
What did you see instead?
If this feature request is accepted, I'd gladly submit a PR to fix it, testing locally the change doesn't have any side effect on current code that expects
multipart/form-data
.The text was updated successfully, but these errors were encountered: