Skip to content

Commit 4835cf4

Browse files
committed
Add missing separator between part custom header name and value, close AsyncHttpClient#1168
1 parent b42c256 commit 4835cf4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

client/src/main/java/org/asynchttpclient/request/body/multipart/part/MultipartPart.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public abstract class MultipartPart<T extends PartBase> implements Closeable {
7676
* Content type header as a byte array
7777
*/
7878
private static final byte[] CONTENT_TRANSFER_ENCODING_BYTES = "Content-Transfer-Encoding: ".getBytes(US_ASCII);
79+
80+
/**
81+
* Content type header as a byte array
82+
*/
83+
private static final byte[] HEADER_NAME_VALUE_SEPARATOR_BYTES = ": ".getBytes(US_ASCII);
7984

8085
/**
8186
* Content type header as a byte array
@@ -303,6 +308,7 @@ protected void visitCustomHeaders(PartVisitor visitor) {
303308
for (Param param : part.getCustomHeaders()) {
304309
visitor.withBytes(CRLF_BYTES);
305310
visitor.withBytes(param.getName().getBytes(US_ASCII));
311+
visitor.withBytes(HEADER_NAME_VALUE_SEPARATOR_BYTES);
306312
visitor.withBytes(param.getValue().getBytes(US_ASCII));
307313
}
308314
}

client/src/test/java/org/asynchttpclient/request/body/multipart/part/MultipartPartTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void testVisitCustomHeaders() {
143143
try (TestMultipartPart multipartPart = new TestMultipartPart(fileLikePart, new byte[0])) {
144144
CounterPartVisitor counterVisitor = new CounterPartVisitor();
145145
multipartPart.visitCustomHeaders(counterVisitor);
146-
assertEquals(counterVisitor.getCount(), 27, "CounterPartVisitor count for visitCustomHeaders should include the length of the custom headers");
146+
assertEquals(counterVisitor.getCount(), 29, "CounterPartVisitor count for visitCustomHeaders should include the length of the custom headers");
147147
}
148148
}
149149

@@ -164,7 +164,7 @@ public void testVisitPreContent() {
164164
try (TestMultipartPart multipartPart = new TestMultipartPart(fileLikePart, new byte[0])) {
165165
CounterPartVisitor counterVisitor = new CounterPartVisitor();
166166
multipartPart.visitPreContent(counterVisitor);
167-
assertEquals(counterVisitor.getCount(), 214, "CounterPartVisitor count for visitPreContent should " + "be equal to the sum of the lengths of precontent");
167+
assertEquals(counterVisitor.getCount(), 216, "CounterPartVisitor count for visitPreContent should " + "be equal to the sum of the lengths of precontent");
168168
}
169169
}
170170

@@ -265,7 +265,5 @@ protected long transferContentTo(ByteBuf target) throws IOException {
265265
protected long transferContentTo(WritableByteChannel target) throws IOException {
266266
return 0;
267267
}
268-
269268
}
270-
271269
}

0 commit comments

Comments
 (0)