u413-284-si / webserv

This project is about setting up a http web server, providing a static website.
MIT License
0 stars 0 forks source link

Handle multipart/formdata requests? #66

Open u413-284-si opened 1 week ago

u413-284-si commented 1 week ago

Implement:

gwolf-011235 commented 1 week ago

Specification for multipart/form-data in RFC 7578 , which obsoletes RFC 2388

See also generally https://www.w3.org/TR/html401/interact/forms.html#h-17.13 on form submission

Re remove headers: if I understood correctly multipart/form-data is used to send files and also send other form data (e.g. path or username or more general "control name"). The content is separated with Content-Disposition headers (so we know where path starts or where file content starts). I think if a file is sent via a form the content-disposition header includes a control name for the file upload (e.g. upload), as well as the filename:

Content-Disposition: form-data; name="files"; filename="file1.txt"

See example in link above.

We don't know what control names might be sent.

We could parse the stuff into a struct similar to http request with control names as "headers", a key value pair (although every control name also has a content-type associated with it). This struct could then be used e.g. for file upload. We can search for "headers" filename and path for file creation.

Or we just expect one control name path and one similar to Content-Disposition: form-data; name="file"; filename="file1.txt"

u413-284-si commented 2 days ago

Question is: how would we convey the parsed control name values to the executed script? As we do it now? Via environment variables?

Generally, yes, this could be implemented with an estimated effort of 1-2 days, but I don't see it as a Must-have. Therefore would leave it out as of now, and if at the end we are good and ready (all required eval criterias are covered) and we still have time before the freeze end, then I would consider adding this feature.