mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 19:21:52 +00:00
LibWeb: Use application/octet-stream for unknown FormData file types
Required by web.whatsapp.com, which uses fetch() to send FormData bodies containing Files with empty types. Ref https://github.com/LadybirdBrowser/ladybird/issues/2941
This commit is contained in:
parent
18b75afef8
commit
3295ed17ea
Notes:
github-actions[bot]
2025-01-29 08:26:33 +00:00
Author: https://github.com/Lubrsi
Commit: 3295ed17ea
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3386
1 changed files with 7 additions and 1 deletions
|
@ -278,7 +278,13 @@ ErrorOr<SerializedFormData> serialize_to_multipart_form_data(Vector<XHR::FormDat
|
|||
// Add a `Content-Disposition` header with a `name` set to entry's name and `filename` set to entry's filename.
|
||||
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()))));
|
||||
// RFC7578: If the contents of a file are to be sent, the file data SHOULD be labeled with an appropriate media type, if known, or
|
||||
// "application/octet-stream".
|
||||
if (!file->type().is_empty()) {
|
||||
TRY(builder.try_append(TRY(String::formatted("Content-Type: {}\r\n\r\n", file->type()))));
|
||||
} else {
|
||||
TRY(builder.try_append("Content-Type: application/octet-stream\r\n\r\n"sv));
|
||||
}
|
||||
TRY(builder.try_append(file->raw_bytes()));
|
||||
TRY(builder.try_append("\r\n"sv));
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue