Allows for the creation of simple HTTP(S) GET clients to acquire data from a given URL.
More...
#include <hdicoreInternetGET.h>
|
| InternetGET (const std::string &url_) |
| Creates a synchronous (blocking) InternetGET object to perform HTTP(S) GET requests, in a "send and forget" fashion.
|
|
| InternetGET (const std::string &url_, const Callback &success_, const Callback &failure_) |
| Creates a synchronous (blocking) InternetGET object to perform HTTP(S) GET requests.
|
|
virtual | ~InternetGET () |
| Destructs an InternetGET object.
|
|
virtual bool | asynchronous () const |
| Gets whether the target object is asynchronous (i.e. executes in a background thread)
|
|
virtual void | run () |
| Starts the GET request.
|
|
virtual bool | running () const |
| Gets whether the GET request is currently running.
|
|
virtual std::string | content () const |
| Gets the content acquired via the GET request.
|
|
virtual InternetError | errorCode () const |
| Gets a translated platform error code, if possible, that was received by the implementation.
|
|
virtual int32_t | platformErrorCode () const |
| Gets the raw platform error code that was received by the implementation.
|
|
virtual std::string | error () const |
| Gets an error description if the GET request failed.
|
|
|
static InternetGET * | Async (const std::string &url_) |
| Creates an asynchronous (non-blocking) InternetGET object to perform HTTP(S) GET requests, in a "send and forget" fashion.
|
|
static InternetGET * | Async (const std::string &url_, const Callback &success_, const Callback &failure_) |
| Creates an asynchronous (non-blocking) InternetGET object to perform HTTP(S) GET requests.
|
|
Allows for the creation of simple HTTP(S) GET clients to acquire data from a given URL.
◆ InternetGET() [1/2]
hdi::core::InternetGET::InternetGET |
( |
const std::string & |
url_ | ) |
|
Creates a synchronous (blocking) InternetGET object to perform HTTP(S) GET requests, in a "send and forget" fashion.
- Author
- GW
- Date
- 09/2019
- Parameters
-
url_ | HTTP(S) URL to read, as UTF-8 |
- Warning
- As this method doesn't take any callback arguments, the request will simply be sent and the caller will never be notified of it finishing/failing.
◆ InternetGET() [2/2]
hdi::core::InternetGET::InternetGET |
( |
const std::string & |
url_, |
|
|
const Callback & |
success_, |
|
|
const Callback & |
failure_ |
|
) |
| |
Creates a synchronous (blocking) InternetGET object to perform HTTP(S) GET requests.
- Author
- GW
- Date
- 07/2014
- Parameters
-
url_ | HTTP(S) URL to read, as UTF-8 |
success_ | Callback to perform when the request completes successfully |
failure_ | Callback to perform when the request fails |
◆ ~InternetGET()
virtual hdi::core::InternetGET::~InternetGET |
( |
| ) |
|
|
virtual |
◆ Async() [1/2]
static InternetGET * hdi::core::InternetGET::Async |
( |
const std::string & |
url_ | ) |
|
|
static |
Creates an asynchronous (non-blocking) InternetGET object to perform HTTP(S) GET requests, in a "send and forget" fashion.
- Author
- GW
- Date
- 09/2019
- Parameters
-
url_ | HTTP(S) URL to read, as UTF-8 |
- Warning
- As this method doesn't take any callback arguments, the request will simply be sent and the caller will never be notified of it finishing/failing.
-
The responsibility for the memory of the returned InternetGET pointer lies with the caller, and it must not be deleted until after either the success or failure callbacks are called.
- Note
- Asynchronous InternetGET objects must be allocated using operator new and have several internal flags set (only synchronous InternetGET objects can be allocated on the stack), which this function does automatically.
◆ Async() [2/2]
Creates an asynchronous (non-blocking) InternetGET object to perform HTTP(S) GET requests.
- Author
- GW
- Date
- 07/2014
- Parameters
-
url_ | HTTP(S) URL to read, as UTF-8 |
success_ | Callback to perform when the request completes successfully |
failure_ | Callback to perform when the request fails |
- Warning
- The responsibility for the memory of the returned InternetGET pointer lies with the caller, and it must not be deleted until after either the success or failure callbacks are called.
- Note
- Asynchronous InternetGET objects must be allocated using operator new and have several internal flags set (only synchronous InternetGET objects can be allocated on the stack), which this function does automatically.
-
The callbacks will not be called if their scheduling comes during or after plugin pre-shutdown (this would lead to a crash on quit).
◆ asynchronous()
virtual bool hdi::core::InternetGET::asynchronous |
( |
| ) |
const |
|
virtual |
Gets whether the target object is asynchronous (i.e. executes in a background thread)
- Author
- GW
- Date
- 07/2014
- Returns
- true for asynchronous, false for synchronous
◆ content()
virtual std::string hdi::core::InternetGET::content |
( |
| ) |
const |
|
virtual |
Gets the content acquired via the GET request.
- Author
- GW
- Date
- 07/2014
- Returns
- The resultant content of the network request, encoded in a string of bytes
- Note
- The std::string return type is slightly misleading; you are not limited to requesting string data. Requesting binary data is perfectly acceptable, as the std::string return type is merely a convenient container.
-
The results of this method are only valid when it is called from the "success" callback (see the InternetGET constructor)
◆ error()
virtual std::string hdi::core::InternetGET::error |
( |
| ) |
const |
|
virtual |
Gets an error description if the GET request failed.
- Author
- GW
- Date
- 07/2014
- Returns
- The resultant error of the request, as UTF-8
- Note
- The results of this method are only valid when it is called from the "failure" callback (see the InternetGET constructor).
◆ errorCode()
virtual InternetError hdi::core::InternetGET::errorCode |
( |
| ) |
const |
|
virtual |
Gets a translated platform error code, if possible, that was received by the implementation.
- Author
- GW
- Date
- 06/2017
- Returns
- The translated platform error code
- Note
- The results of this method are only valid when it is called from the "failure" callback (see the InternetGET constructor).
◆ platformErrorCode()
virtual int32_t hdi::core::InternetGET::platformErrorCode |
( |
| ) |
const |
|
virtual |
Gets the raw platform error code that was received by the implementation.
- Author
- GW
- Date
- 06/2017
- Returns
- The translated platform error code
- Note
- See the file NSURLError.h on Mac, and WinINet.h on Windows, for a list of possible platform error codes.
-
The results of this method are only valid when it is called from the "failure" callback (see the InternetGET constructor).
◆ run()
virtual void hdi::core::InternetGET::run |
( |
| ) |
|
|
virtual |
Starts the GET request.
- Author
- GW
- Date
- 07/2014
◆ running()
virtual bool hdi::core::InternetGET::running |
( |
| ) |
const |
|
virtual |
Gets whether the GET request is currently running.
- Author
- GW
- Date
- 07/2014
- Returns
- true if the request is running, false otherwise