Class FormBodyPartBuilder
java.lang.Object
org.apache.hc.client5.http.entity.mime.FormBodyPartBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContentBodyprivate final Headerprivate CharsetEncoderEncoder used to check if strings can be encoded in ISO-8859-1, supporting filename compatibility determinations in multipart form data.private HttpMultipartModeThe multipart mode determining how filenames are encoded in theContent-Dispositionheader, defaults toHttpMultipartMode.STRICT.private String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()private booleancanEncodeToISO8859_1(String input) Determines whether the given string can be encoded in ISO-8859-1 without loss of data.static FormBodyPartBuildercreate()static FormBodyPartBuildercreate(String name, ContentBody body) static FormBodyPartBuildercreate(String name, ContentBody body, HttpMultipartMode mode) Creates a new builder instance with the specified name, content body, and multipart mode.private static StringencodeRFC5987(String filename) Encodes the given filename according to RFC 5987, prefixing it withUTF-8''and applying percent-encoding to non-ASCII characters.removeFields(String name) setBody(ContentBody body)
-
Field Details
-
name
-
body
-
header
-
mode
The multipart mode determining how filenames are encoded in theContent-Dispositionheader, defaults toHttpMultipartMode.STRICT.- Since:
- 5.5
-
iso8859_1Encoder
Encoder used to check if strings can be encoded in ISO-8859-1, supporting filename compatibility determinations in multipart form data.
-
-
Constructor Details
-
FormBodyPartBuilder
FormBodyPartBuilder(String name, ContentBody body, HttpMultipartMode mode) -
FormBodyPartBuilder
FormBodyPartBuilder()
-
-
Method Details
-
create
Creates a new builder instance with the specified name, content body, and multipart mode.- Parameters:
name- the name of the form fieldbody- the content body of the partmode- theHttpMultipartModeto use, determining filename encoding behavior;- Returns:
- a new
FormBodyPartBuilderinstance - Since:
- 5.5
-
create
-
create
-
setName
-
setBody
-
addField
public FormBodyPartBuilder addField(String name, String value, List<org.apache.hc.core5.http.NameValuePair> parameters) - Since:
- 4.6
-
addField
-
setField
-
removeFields
-
canEncodeToISO8859_1
Determines whether the given string can be encoded in ISO-8859-1 without loss of data. This is used to decide whether thefilenameparameter can be used as-is or if thefilename*parameter is needed for non-ISO-8859-1 characters.- Parameters:
input- the string to check, must not benull- Returns:
trueif the string can be encoded in ISO-8859-1,falseotherwise- Since:
- 5.5
-
encodeRFC5987
Encodes the given filename according to RFC 5987, prefixing it withUTF-8''and applying percent-encoding to non-ASCII characters. This is used for thefilename*parameter in theContent-Dispositionheader when non-ISO-8859-1 characters are present.- Parameters:
filename- the filename to encode, must not benull- Returns:
- the RFC 5987-encoded string, e.g.,
UTF-8''example%20text - Since:
- 5.5
-
build
-