⚠️ The annual cost of maintaining the server where this website is hosted, the domain, and keeping it up-to-date is approximately €3,000 per year. Help us with a small donation to cover these expenses. Support Now!

0 / 10000
dw.net
Class HTTPRequestPart
Object
dw.net.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.

Properties
bytesValue  :  Bytes  (Read Only)
Get the Bytes value of the part.
contentType  :  String  (Read Only)
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 Summary
HTTPRequestPart(name : String, value : String)
Construct a part representing a simple string name/value pair.
HTTPRequestPart(name : String, value : String, encoding : String)
Construct a part representing a simple string name/value pair.
HTTPRequestPart(name : String, file : File)
Construct a part representing a name/File pair.
HTTPRequestPart(name : String, data : Bytes)
Construct a part representing a name/bytes pair.
HTTPRequestPart(name : String, data : Bytes, contentType : String, encoding : String, fileName : String)
Construct a part representing a name/File pair.
HTTPRequestPart(name : String, file : File, contentType : String, encoding : String)
Construct a part representing a name/File pair.
HTTPRequestPart(name : String, file : File, contentType : String, encoding : String, fileName : String)
Construct a part representing a name/File pair.
Method Summary
getBytesValue() : Bytes
Get the Bytes value of the part.
getContentType() : String
Returns the content type of this part.
getEncoding() : String
Get the charset to be used to encode the string.
getFileName() : String
Get the file name to use when sending a file part.
getFileValue() : File
Get the file value of the part.
getName() : String
Get the name of the part.
getStringValue() : String
Get the string value of the part.
Constructor Detail
HTTPRequestPart
public 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
public 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
public 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
public 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
public 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
public 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
public 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.

Method Detail
getBytesValue
getBytesValue() : Bytes
Get the Bytes value of the part.
Returns:
The Bytes value, or null if this part is not a Bytes part.

getContentType
getContentType() : String
Returns the content type of this part.
Returns:
The content type, or null if content type was not specified.

getEncoding
getEncoding() : String
Get the charset to be used to encode the string.
Returns:
The charset, or null if charset was not specified.

getFileName
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
getFileValue() : File
Get the file value of the part.
Returns:
The file value, or null if this part is not a file part.

getName
getName() : String
Get the name of the part.
Returns:
The part name, never null.

getStringValue
getStringValue() : String
Get the string value of the part.
Returns:
The string value, or null if this part is not a string part.