@Override
    protected void formatMultipartHeader(final MultipartPart part, final OutputStream out) throws IOException {
        for (final MimeField field: part.getHeader()) {
            if (MimeConsts.CONTENT_DISPOSITION.equalsIgnoreCase(field.getName())) {
                writeBytes(field.getName(), charset, out);
                writeBytes(FIELD_SEP, out);
                writeBytes(field.getValue(), out);
                final List<NameValuePair> parameters = field.getParameters();
                for (int i = 0; i < parameters.size(); i++) {
                    final NameValuePair parameter = parameters.get(i);
                    final String name = parameter.getName();
                    final String value = parameter.getValue();
                    writeBytes("; ", out);
                    writeBytes(name, out);
                    writeBytes("=\"", out);
                    if (value != null) {
                        if (name.equalsIgnoreCase(MimeConsts.FIELD_PARAM_FILENAME_START)) {
                            final String encodedValue = "UTF-8''" + PercentCodec.RFC5987.encode(value);
                            writeBytes(encodedValue, StandardCharsets.US_ASCII, out);
                        } else if (name.equalsIgnoreCase(MimeConsts.FIELD_PARAM_FILENAME)) {
                            if (mode == HttpMultipartMode.EXTENDED) {
                                final String encodedValue = PercentCodec.RFC5987.encode(value);
                                writeBytes(encodedValue, StandardCharsets.US_ASCII, out);
                            } else {
                                // Default to ISO-8859-1 for RFC 7578 compliance in STRICT/LEGACY
                                writeBytes(value, StandardCharsets.ISO_8859_1, out);
                            }
                        } else {
                            writeBytes(value, out);
                        }
                    }
                    writeBytes("\"", out);
                }
                writeBytes(CR_LF, out);
            } else {
                writeField(field, charset, out);
            }
        }
    }
Constructs a new instance of {@code HttpRFC7578Multipart} with the given charset, boundary, and parts.

@param charset  the charset to use.
@param boundary the boundary string to use.
@param parts    the list of parts to include in the multipart message.
httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/HttpRFC7578Multipart.java