Skip to content

Commit 024bbb7

Browse files
authored
[Rust Server] Improve RFC 13341 compliance for multipart/related (#19355)
* [Rust Server] Improve RFC 13341 compliance for multipart/related * Update samples
1 parent be09f8a commit 024bbb7

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

modules/openapi-generator/src/main/resources/rust-server/generate-multipart-related.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
{{#-last}}
3131

3232
// Write the body into a vec.
33-
let mut body: Vec<u8> = vec![];
33+
// RFC 13341 Section 7.2.1 suggests that the body should begin with a
34+
// CRLF prior to the first boundary. The mime_multipart library doesn't
35+
// do this, so we do it instead.
36+
let mut body: Vec<u8> = vec![b'\r', b'\n'];
3437
write_multipart(&mut body, &boundary, &body_parts)
3538
.expect("Failed to write multipart body");
3639
{{/-last}}

samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,10 @@ impl<S, C> Api<C> for Client<S, C> where
469469
}
470470

471471
// Write the body into a vec.
472-
let mut body: Vec<u8> = vec![];
472+
// RFC 13341 Section 7.2.1 suggests that the body should begin with a
473+
// CRLF prior to the first boundary. The mime_multipart library doesn't
474+
// do this, so we do it instead.
475+
let mut body: Vec<u8> = vec![b'\r', b'\n'];
473476
write_multipart(&mut body, &boundary, &body_parts)
474477
.expect("Failed to write multipart body");
475478

@@ -741,7 +744,10 @@ impl<S, C> Api<C> for Client<S, C> where
741744
}
742745

743746
// Write the body into a vec.
744-
let mut body: Vec<u8> = vec![];
747+
// RFC 13341 Section 7.2.1 suggests that the body should begin with a
748+
// CRLF prior to the first boundary. The mime_multipart library doesn't
749+
// do this, so we do it instead.
750+
let mut body: Vec<u8> = vec![b'\r', b'\n'];
745751
write_multipart(&mut body, &boundary, &body_parts)
746752
.expect("Failed to write multipart body");
747753

0 commit comments

Comments
 (0)