rwf2 / multer

An async parser for multipart/form-data content-type in Rust
MIT License
156 stars 35 forks source link

Clarify Field.name in relation to the RFC #51

Closed jaysonsantos closed 1 year ago

jaysonsantos commented 1 year ago

Hi there, this is not a bug per se but, I would like to clarify the function Field.name() which returns an option but, on the pointed doc it says that for a header for multipart body it is mandatory. The question is, on multer is it optional because can be used to represent both the multipart body's and the HTTP headers?

SergioBenitez commented 1 year ago

No, I don't think that's why. This library tries to strike a good balance between faithfully following the spec while also being aware of what happens in the real world to ensure applications using multer actually work in the wild. It's not unheard of for clients to send fields without field names, and so outright rejecting such fields would mean not functioning with that class of clients. In that case the field would be None, of course. What's more, this allows applications to choose whether to reject fields without names (such as Rocket does) or not by simply filtering out fields via name.is_none().