@@ -41,7 +41,17 @@ public abstract class Part {
41
41
/**
42
42
* Content dispostion as a byte array
43
43
*/
44
- public static final byte [] CONTENT_DISPOSITION_BYTES = "Content-Disposition: form-data; name=" .getBytes (StandardCharsets .US_ASCII );
44
+ public static final byte [] CONTENT_DISPOSITION_BYTES = "Content-Disposition: " .getBytes (StandardCharsets .US_ASCII );
45
+
46
+ /**
47
+ * form-data as a byte array
48
+ */
49
+ public static final byte [] FORM_DATA_DISPOSITION_TYPE_BYTES = "form-data" .getBytes (StandardCharsets .US_ASCII );
50
+
51
+ /**
52
+ * name as a byte array
53
+ */
54
+ public static final byte [] NAME_BYTES = "; name=" .getBytes (StandardCharsets .US_ASCII );
45
55
46
56
/**
47
57
* Content type header as a byte array
@@ -108,6 +118,20 @@ public boolean isRepeatable() {
108
118
return true ;
109
119
}
110
120
121
+ private String dispositionType ;
122
+ /**
123
+ * Gets the disposition-type to be used in Content-Disposition header
124
+ *
125
+ * @return the disposition-type
126
+ */
127
+ public String getDispositionType () {
128
+ return dispositionType ;
129
+ }
130
+
131
+ public void setDispositionType (String dispositionType ) {
132
+ this .dispositionType = dispositionType ;
133
+ }
134
+
111
135
protected void visitStart (PartVisitor visitor , byte [] boundary ) throws IOException {
112
136
visitor .withBytes (EXTRA_BYTES );
113
137
visitor .withBytes (boundary );
@@ -117,6 +141,8 @@ protected void visitDispositionHeader(PartVisitor visitor) throws IOException {
117
141
if (getName () != null ) {
118
142
visitor .withBytes (CRLF_BYTES );
119
143
visitor .withBytes (CONTENT_DISPOSITION_BYTES );
144
+ visitor .withBytes (dispositionType != null ? dispositionType .getBytes (StandardCharsets .US_ASCII ): FORM_DATA_DISPOSITION_TYPE_BYTES );
145
+ visitor .withBytes (NAME_BYTES );
120
146
visitor .withBytes (QUOTE_BYTES );
121
147
visitor .withBytes (getName ().getBytes (StandardCharsets .US_ASCII ));
122
148
visitor .withBytes (QUOTE_BYTES );
0 commit comments