diff --git a/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp index 9a80d793c2f..ea6b45c81da 100644 --- a/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp +++ b/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp @@ -278,7 +278,13 @@ ErrorOr serialize_to_multipart_form_data(Vectortype())))); + // 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 {};