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 94ab9db18c2..59b647a4130 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 @@ -30,7 +30,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 9f6583b96c4..42a5fbc96b8 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 @@ -469,7 +469,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"); @@ -741,7 +744,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");