Skip to content

Commit 4fa982b

Browse files
committed
format code
1 parent bc7ac12 commit 4fa982b

File tree

6 files changed

+592
-601
lines changed

6 files changed

+592
-601
lines changed

scribejava-httpclient-armeria/src/main/java/com/github/scribejava/core/httpclient/multipart/MultipartUtils.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,47 @@
77

88
public abstract class MultipartUtils {
99

10-
// copied from com.github.scribejava.core.httpclient.jdk.JDKHttpClient#getPayload
11-
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException {
12-
final ByteArrayOutputStream os = new ByteArrayOutputStream();
10+
// copied from com.github.scribejava.core.httpclient.jdk.JDKHttpClient#getPayload
11+
public static ByteArrayOutputStream getPayload(MultipartPayload multipartPayload) throws IOException {
12+
final ByteArrayOutputStream os = new ByteArrayOutputStream();
1313

14-
final String preamble = multipartPayload.getPreamble();
15-
if (preamble != null) {
16-
os.write(preamble.getBytes());
17-
}
18-
final List<BodyPartPayload> bodyParts = multipartPayload.getBodyParts();
19-
if (!bodyParts.isEmpty()) {
20-
final String boundary = multipartPayload.getBoundary();
21-
final byte[] startBoundary = ("\r\n--" + boundary + "\r\n").getBytes();
22-
23-
for (BodyPartPayload bodyPart : bodyParts) {
24-
os.write(startBoundary);
25-
26-
final Map<String, String> bodyPartHeaders = bodyPart.getHeaders();
27-
if (bodyPartHeaders != null) {
28-
for (Map.Entry<String, String> header : bodyPartHeaders.entrySet()) {
29-
os.write((header.getKey() + ": " + header.getValue() + "\r\n").getBytes());
30-
}
14+
final String preamble = multipartPayload.getPreamble();
15+
if (preamble != null) {
16+
os.write(preamble.getBytes());
3117
}
18+
final List<BodyPartPayload> bodyParts = multipartPayload.getBodyParts();
19+
if (!bodyParts.isEmpty()) {
20+
final String boundary = multipartPayload.getBoundary();
21+
final byte[] startBoundary = ("\r\n--" + boundary + "\r\n").getBytes();
22+
23+
for (BodyPartPayload bodyPart : bodyParts) {
24+
os.write(startBoundary);
25+
26+
final Map<String, String> bodyPartHeaders = bodyPart.getHeaders();
27+
if (bodyPartHeaders != null) {
28+
for (Map.Entry<String, String> header : bodyPartHeaders.entrySet()) {
29+
os.write((header.getKey() + ": " + header.getValue() + "\r\n").getBytes());
30+
}
31+
}
32+
33+
if (bodyPart instanceof MultipartPayload) {
34+
getPayload((MultipartPayload) bodyPart).writeTo(os);
35+
} else if (bodyPart instanceof ByteArrayBodyPartPayload) {
36+
os.write("\r\n".getBytes());
37+
os.write(((ByteArrayBodyPartPayload) bodyPart).getPayload());
38+
} else {
39+
throw new AssertionError(bodyPart.getClass());
40+
}
41+
}
42+
43+
os.write(("\r\n--" + boundary + "--\r\n").getBytes());
44+
final String epilogue = multipartPayload.getEpilogue();
45+
if (epilogue != null) {
46+
os.write((epilogue + "\r\n").getBytes());
47+
}
3248

33-
if (bodyPart instanceof MultipartPayload) {
34-
getPayload((MultipartPayload) bodyPart).writeTo(os);
35-
} else if (bodyPart instanceof ByteArrayBodyPartPayload) {
36-
os.write("\r\n".getBytes());
37-
os.write(((ByteArrayBodyPartPayload) bodyPart).getPayload());
38-
} else {
39-
throw new AssertionError(bodyPart.getClass());
4049
}
41-
}
42-
43-
os.write(("\r\n--" + boundary + "--\r\n").getBytes());
44-
final String epilogue = multipartPayload.getEpilogue();
45-
if (epilogue != null) {
46-
os.write((epilogue + "\r\n").getBytes());
47-
}
48-
50+
return os;
4951
}
50-
return os;
51-
}
5252

5353
}

0 commit comments

Comments
 (0)