Hot Door CORE  0.7.1
Adobe® Illustrator® Plug-in Library
Public Member Functions | Static Public Member Functions | List of all members
hdi::core::InternetGET Class Reference

Allows for the creation of simple HTTP(S) GET clients to acquire data from a given URL. More...

#include <hdicoreInternetGET.h>

Public Member Functions

 InternetGET (const std::string &url_, const Callback &success_, const Callback &failure_)
 Creates a synchronous (blocking) InternetGET object to perform HTTP(S) GET requests. More...
 
virtual ~InternetGET ()
 Destructs an InternetGET object. More...
 
virtual bool asynchronous () const
 Gets whether the target object is asynchronous (i.e. executes in a background thread) More...
 
virtual void run ()
 Starts the GET request. More...
 
virtual bool running () const
 Gets whether the GET request is currently running. More...
 
virtual std::string content () const
 Gets the content acquired via the GET request. More...
 
virtual InternetError errorCode () const
 Gets a translated platform error code, if possible, that was received by the implementation. More...
 
virtual int32_t platformErrorCode () const
 Gets the raw platform error code that was received by the implementation. More...
 
virtual std::string error () const
 Gets an error description if the GET request failed. More...
 

Static Public Member Functions

static InternetGETAsync (const std::string &url_, const Callback &success_, const Callback &failure_)
 Creates an asynchronous (non-blocking) InternetGET object to perform HTTP(S) GET requests. More...
 

Detailed Description

Allows for the creation of simple HTTP(S) GET clients to acquire data from a given URL.

Constructor & Destructor Documentation

◆ InternetGET()

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
Note
The callbacks will not be called if their scheduling comes during or after plugin pre-shutdown (this would lead to a crash on quit).

◆ ~InternetGET()

virtual hdi::core::InternetGET::~InternetGET ( )
virtual

Destructs an InternetGET object.

Author
GW
Date
07/2014

Member Function Documentation

◆ Async()

static InternetGET* hdi::core::InternetGET::Async ( const std::string &  url_,
const Callback success_,
const Callback failure_ 
)
static

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