Class HTTPRequestPart
This represents a part in a multi-part HTTP POST request.
A part always has a name and value. The value may be a String, Bytes, or the contents of a File.
A character encoding may be specified for any of these, and the content type and a file name may additionally be specified for the Bytes and File types.
Note: when this class is used with sensitive data, be careful in persisting sensitive information.
| Property | Description |
|---|---|
bytesValue: Bytes (read-only) | Get the Bytes value of the part. |
contentType: String (read-only) | Returns the content type of this part. |
encoding: String (read-only) | Get the charset to be used to encode the string. |
fileName: String (read-only) | Get the file name to use when sending a file part. |
fileValue: File (read-only) | Get the file value of the part. |
name: String (read-only) | Get the name of the part. |
stringValue: String (read-only) | Get the string value of the part. |
| Constructor | Description |
|---|---|
| HTTPRequestPart(String, String) | Construct a part representing a simple string name/value pair. |
| HTTPRequestPart(String, String, String) | Construct a part representing a simple string name/value pair. |
| HTTPRequestPart(String, File) | Construct a part representing a name/File pair. |
| HTTPRequestPart(String, Bytes) | Construct a part representing a name/bytes pair. |
| HTTPRequestPart(String, Bytes, String, String, String) | Construct a part representing a name/File pair. |
| HTTPRequestPart(String, File, String, String) | Construct a part representing a name/File pair. |
| HTTPRequestPart(String, File, String, String, String) | Construct a part representing a name/File pair. |
| Method | Description |
|---|---|
| getBytesValue() | Get the Bytes value of the part. |
| getContentType() | Returns the content type of this part. |
| getEncoding() | Get the charset to be used to encode the string. |
| getFileName() | Get the file name to use when sending a file part. |
| getFileValue() | Get the file value of the part. |
| getName() | Get the name of the part. |
| getStringValue() | Get the string value of the part. |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- bytesValue: Bytes
(read-only) Get the Bytes value of the part.
- contentType: String
(read-only) Returns the content type of this part.
- encoding: String
(read-only) Get the charset to be used to encode the string.
- fileName: String
(read-only) Get the file name to use when sending a file part.
- fileValue: File
(read-only) Get the file value of the part.
- name: String
(read-only) Get the name of the part.
- stringValue: String
(read-only) Get the string value of the part.
- HTTPRequestPart(name: String, value: String)
Construct a part representing a simple string name/value pair. The HTTP message uses "US-ASCII" as the default character set for the part.
Parameters:
- name - The name of the part.
- value - The string to post.
- HTTPRequestPart(name: String, value: String, encoding: String)
Construct a part representing a simple string name/value pair. The HTTP message uses the specified encoding or "US-ASCII" if null is passed for the part.
Parameters:
- name - The name of the part.
- value - The string to post.
- encoding - The charset to be used to encode the string, if null the default is used.
- HTTPRequestPart(name: String, file: File)
Construct a part representing a name/File pair. The HTTP message will use "application/octet-stream" as the content type and "ISO-8859-1" as the character set for the part.
Parameters:
- name - The name of the file part
- file - The file to post
- HTTPRequestPart(name: String, data: Bytes)
Construct a part representing a name/bytes pair. The HTTP message will use "application/octet-stream" as the content type without a character set.
Parameters:
- name - The name of the file part
- data - The bytes to post
- HTTPRequestPart(name: String, data: Bytes, contentType: String, encoding: String, fileName: String)
Construct a part representing a name/File pair.
- If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream" as the content-type without an encoding. - If only the encoding is null, then the contentType will be used without an encoding. - If only the contentType is null, then it will be defaulted to "text/plain".
Parameters:
- name - The name of the file part
- data - The bytes to post
- contentType - The content type for this part, if null or blank the default is used.
- encoding - the charset encoding for this part, if null or blank the default is used.
- fileName - The file name to use in the Mime header, or null to not use one.
- HTTPRequestPart(name: String, file: File, contentType: String, encoding: String)
Construct a part representing a name/File pair.
- If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream" as the content-type and "ISO-8859-1" as the encoding. - If only the encoding is null, then the contentType will be used without an encoding. - If only the contentType is null, then it will be defaulted to "text/plain".
Parameters:
- name - The name of the file part
- file - The file to post
- contentType - The content type for this part, if null or blank the default is used.
- encoding - the charset encoding for this part, if null or blank the default is used
- HTTPRequestPart(name: String, file: File, contentType: String, encoding: String, fileName: String)
Construct a part representing a name/File pair.
- If both contentType and encoding are null, then the part will be defaulted to use "application/octet-stream" as the content-type and "ISO-8859-1" as the encoding. - If only the encoding is null, then the contentType will be used without an encoding. - If only the contentType is null, then it will be defaulted to "text/plain".
Parameters:
- name - The name of the file part
- file - The file to post
- contentType - The content type for this part, if null or blank the default is used.
- encoding - the charset encoding for this part, if null or blank the default is used
- fileName - The file name to use in the Mime header, or null to use the name of the given file.
- getBytesValue(): Bytes
Get the Bytes value of the part.
Returns:
- The Bytes value, or null if this part is not a Bytes part.
- getContentType(): String
Returns the content type of this part.
Returns:
- The content type, or null if content type was not specified.
- getEncoding(): String
Get the charset to be used to encode the string.
Returns:
- The charset, or null if charset was not specified.
- getFileName(): String
Get the file name to use when sending a file part.
Returns:
- File name to use in the Mime header, or null for default behavior.
- getFileValue(): File
Get the file value of the part.
Returns:
- The file value, or null if this part is not a file part.
- getName(): String
Get the name of the part.
Returns:
- The part name, never null.
- getStringValue(): String
Get the string value of the part.
Returns:
- The string value, or null if this part is not a string part.