PostRequest
Last updated
Last updated
The PostRequest
class is designed for constructing and executing HTTP POST requests. It allows adding files, parameters, and headers to requests, with automatic MIME type detection based on file names or content. Users can override MIME type detection when needed. The class supports single-file and multipart configurations, with an option to enforce multipart formatting even for single files or parameters.
Requests can be executed synchronously or asynchronously. Asynchronous methods allow non-blocking operations and support callbacks for success and error handling. They also include support for Windows authentication and additional arguments to differentiate callbacks in complex workflows. Synchronous methods return a Response
object for direct interaction with server replies.
The class includes features for setting authentication, such as preemptive credentials, which are useful for optimizing uploads to servers requiring immediate authentication.
A sample for creating a PostRequest
instance can be found here: createPostRequest.
Type | Name | Summary |
---|---|---|
Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).
Parameters
Returns: Boolean
Sample
Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).
Parameters
String parameterName ;
Object jsFile ;
String mimeType The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.
Returns: Boolean
Sample
Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).
Parameters
Returns: Boolean
Sample
Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).
Parameters
String parameterName ;
String fileName ;
Object jsFile ;
String mimeType The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.
Returns: Boolean
Sample
Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or a file and at least a parameter via addParameter(...).
Parameters
Returns: Boolean
Sample
Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).
If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).
Parameters
String parameterName ;
String fileName ;
String fileLocation ;
String mimeType The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.
Returns: Boolean
Sample