LibWeb: Append the bytes of File objects in submitted form data

This is required to upload files to GitHub. Unfortunately, this is not
currently testable with our test infrastructure. This path is only hit
from HTTP/S uploads, whereas all of our tests are limited to file://.
This commit is contained in:
Timothy Flynn 2024-03-13 17:10:41 -04:00 committed by Andreas Kling
commit bc23c5b9fe
Notes: sideshowbarker 2024-07-17 01:06:10 +09:00

View file

@ -270,7 +270,7 @@ ErrorOr<SerializedFormData> serialize_to_multipart_form_data(Vector<XHR::FormDat
TRY(builder.try_append(TRY(String::formatted("Content-Disposition: form-data; name=\"{}\"; filename=\"{}\"\r\n", escaped_name, escaped_filename))));
// The parts of the generated multipart/form-data resource that correspond to file fields must have a `Content-Type` header specified.
TRY(builder.try_append(TRY(String::formatted("Content-Type: {}\r\n\r\n", file->type()))));
// FIXME: Serialize the contents of the file.
TRY(builder.try_append(file->bytes()));
TRY(builder.try_append("\r\n"sv));
return {};
},