multipart/form-data and file size

784 views
Skip to first unread message

Manlio Perillo

unread,
Feb 6, 2017, 4:54:57 AM2/6/17
to golang-nuts
Hi.

I have noted that the implementation of multipart.Reader.ReadForm *knows* the size of
a file, but it just discards it.   Isn't it better if it make it available as a field in the FileHeader
or, probably better as an additional Content-Length header?

RFC 7578 says "The multipart/form-data media type does not support any MIME headerields in parts other than Content-Type, Content-Disposition, and (in limited circumstances) Content-Transfer-Encoding. Other header fields MUST NOT be included and MUST be ignored", however this does not mean that a client implementation can not add the Content-Length header.

Knowing the size of an uploaded file without having to read the content again may be useful.


Thanks
Manlio

Jesper Louis Andersen

unread,
Feb 6, 2017, 7:34:53 AM2/6/17
to Manlio Perillo, golang-nuts
I think it is a good idea. The only thing you should check before going for it is what other clients are doing. Some times what is in the RFC is not what has been implemented in reality. This can mean that if you start following the RFC spec, you end up breaking some clients in the process, which can be why such things are left out. In general, multipart is an angry beehive of stuff.



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages