260806_01_ENH: multipart 데이터 ascii -> utf-8로 변경
This commit is contained in:
@@ -136,20 +136,20 @@ public class ExternalApiClient {
|
||||
throw new IllegalArgumentException("parts must not contain null");
|
||||
}
|
||||
|
||||
writeAscii(out, "--" + boundary + CRLF);
|
||||
writeAscii(out, "Content-Disposition: form-data; name=\"" + headerValue(part.getName()) + "\"");
|
||||
writeUtf8(out, "--" + boundary + CRLF);
|
||||
writeUtf8(out, "Content-Disposition: form-data; name=\"" + headerValue(part.getName()) + "\"");
|
||||
if (part.getFilename() != null) {
|
||||
writeAscii(out, "; filename=\"" + headerValue(part.getFilename()) + "\"");
|
||||
writeUtf8(out, "; filename=\"" + headerValue(part.getFilename()) + "\"");
|
||||
}
|
||||
writeAscii(out, CRLF);
|
||||
writeUtf8(out, CRLF);
|
||||
if (part.getContentType() != null && !part.getContentType().isBlank()) {
|
||||
writeAscii(out, "Content-Type: " + safeHeader(part.getContentType()) + CRLF);
|
||||
writeUtf8(out, "Content-Type: " + safeHeader(part.getContentType()) + CRLF);
|
||||
}
|
||||
writeAscii(out, CRLF);
|
||||
writeUtf8(out, CRLF);
|
||||
out.write(part.content());
|
||||
writeAscii(out, CRLF);
|
||||
writeUtf8(out, CRLF);
|
||||
}
|
||||
writeAscii(out, "--" + boundary + "--" + CRLF);
|
||||
writeUtf8(out, "--" + boundary + "--" + CRLF);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
@@ -165,8 +165,10 @@ public class ExternalApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
private static void writeAscii(ByteArrayOutputStream out, String value) throws IOException {
|
||||
out.write(value.getBytes(StandardCharsets.US_ASCII));
|
||||
private static void writeUtf8(ByteArrayOutputStream out, String value) throws IOException {
|
||||
// Multipart delimiters remain byte-identical because UTF-8 is ASCII-compatible, while
|
||||
// user-visible field names and filenames retain non-ASCII characters.
|
||||
out.write(value.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private static String headerValue(String value) {
|
||||
|
||||
Reference in New Issue
Block a user