diff --git a/modules/openapi-generator/src/main/resources/rust-server/generate-multipart-related.mustache b/modules/openapi-generator/src/main/resources/rust-server/generate-multipart-related.mustache index ff2330c07d4d..352273790bff 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/generate-multipart-related.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/generate-multipart-related.mustache @@ -39,7 +39,10 @@ {{#-last}} // Write the body into a vec. - let mut body: Vec = vec![]; + // RFC 13341 Section 7.2.1 suggests that the body should begin with a + // CRLF prior to the first boundary. The mime_multipart library doesn't + // do this, so we do it instead. + let mut body: Vec = vec![b'\r', b'\n']; write_multipart(&mut body, &boundary, &body_parts) .expect("Failed to write multipart body"); {{/-last}} diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs index 2d52eec0a593..4e4f13bccd91 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs @@ -478,7 +478,10 @@ impl Api for Client where } // Write the body into a vec. - let mut body: Vec = vec![]; + // RFC 13341 Section 7.2.1 suggests that the body should begin with a + // CRLF prior to the first boundary. The mime_multipart library doesn't + // do this, so we do it instead. + let mut body: Vec = vec![b'\r', b'\n']; write_multipart(&mut body, &boundary, &body_parts) .expect("Failed to write multipart body"); @@ -759,7 +762,10 @@ impl Api for Client where } // Write the body into a vec. - let mut body: Vec = vec![]; + // RFC 13341 Section 7.2.1 suggests that the body should begin with a + // CRLF prior to the first boundary. The mime_multipart library doesn't + // do this, so we do it instead. + let mut body: Vec = vec![b'\r', b'\n']; write_multipart(&mut body, &boundary, &body_parts) .expect("Failed to write multipart body");