|
10Duke Enterprise C++ SDK
|
#include <HTTPRequestBuilder.h>
Builds HTTPRequest.
Public Member Functions | |
| HTTPRequestBuilder (const ::tenduke::net::URLs &urls, tenduke::http::HTTPClient *client=nullptr, long connectionTimeoutMs=tenduke::http::DEFAULT_CONNECTION_TIMEOUT_MS, long timeoutMs=tenduke::http::DEFAULT_TIMEOUT_MS) | |
| Constructs new instance. | |
| std::unique_ptr< HTTPRequest > | build () |
| Builds the request. | |
| std::unique_ptr< HTTPCall > | call () |
| Builds the request, and builds the call in one call. | |
| HTTPRequestBuilder & | get () |
| Sets the method to GET. | |
| HTTPRequestBuilder & | post () |
| Sets the method to POST. | |
| HTTPRequestBuilder & | url (const std::string &url) |
| Sets the request URL. | |
| HTTPRequestBuilder & | url (const ::tenduke::net::URL &url) |
| Sets the request URL. | |
| HTTPRequestBuilder & | authenticateWith (const std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > &requestAuthenticator) |
| Sets the request authenticator. | |
| HTTPRequestBuilder & | header (const std::string &name, const std::string &value, bool skipIfValueEmpty=true) |
| Adds header to the request. | |
| HTTPRequestBuilder & | formParameter (const std::string &name, const std::string &value) |
| Adds form-parameter to the request. | |
| HTTPRequestBuilder & | contentType (const std::string &contentType) |
| Sets content-type. | |
| HTTPRequestBuilder & | charset (const std::string &charset) |
| Sets character set. | |
| HTTPRequestBuilder & | utf8 () |
| Sets the character set to UTF-8. | |
| HTTPRequestBuilder & | body (const std::string &requestEntity) |
| Sets body as string. | |
| tenduke::net::URLBuilder | createURL () const |
| Starts URL-building. | |
| ::tenduke::net::URLBuilder | createURL (const ::tenduke::net::URL &url) const |
| Starts URL-building, initialized from given URL. | |
| ::tenduke::net::URLBuilder | createURL (const std::string &url) const |
| Starts URL-building, initialized from given URL. | |
Protected Member Functions | |
| std::string | buildMessageBodyFromFormParameters () |
| Builds the message body from form-parameters. | |
|
explicit |
Constructs new instance.
| urls | - |
| client | - |
| connectionTimeoutMs | - |
| timeoutMs | - |
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::authenticateWith | ( | const std::shared_ptr< const tenduke::http::HTTPRequestAuthenticator > & | requestAuthenticator | ) |
Sets the request authenticator.
| requestAuthenticator | - |
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::body | ( | const std::string & | requestEntity | ) |
Sets body as string.
| requestEntity | - |
| std::unique_ptr< xdhttp::HTTPRequest > tenduke::http::HTTPRequestBuilder::build | ( | ) |
Builds the request.
|
protected |
Builds the message body from form-parameters.
| std::unique_ptr< xdhttp::HTTPCall > tenduke::http::HTTPRequestBuilder::call | ( | ) |
Builds the request, and builds the call in one call.
NOTE: if HTTP-client not present, you will get an exception.
Remember to execute the call.
| tenduke::http::HTTPException | if the builder has not been configured with HTTP-client |
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::charset | ( | const std::string & | charset | ) |
Sets character set.
| charset | - |
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::contentType | ( | const std::string & | contentType | ) |
Sets content-type.
| contentType | - |
Starts URL-building.
| URLBuilder tenduke::http::HTTPRequestBuilder::createURL | ( | const ::tenduke::net::URL & | url | ) | const |
| URLBuilder tenduke::http::HTTPRequestBuilder::createURL | ( | const std::string & | url | ) | const |
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::formParameter | ( | const std::string & | name, |
| const std::string & | value ) |
Adds form-parameter to the request.
The method will PCT-encode the parameter (name and value).
| name | - |
| value | - |
Sets the method to GET.
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::header | ( | const std::string & | name, |
| const std::string & | value, | ||
| bool | skipIfValueEmpty = true ) |
Adds header to the request.
| name | name of the header |
| value | value of the header |
| skipIfValueEmpty | if true and value is empty, the header will not be added. |
Sets the method to POST.
| xdhttp::HTTPRequestBuilder & tenduke::http::HTTPRequestBuilder::url | ( | const std::string & | url | ) |
Sets the character set to UTF-8.
(Syntactic sugar).