Hot Door CORE  0.7.0
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 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

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).
virtual hdi::core::InternetGET::~InternetGET ( )
virtual

Destructs an InternetGET object.

Author
GW
Date
07/2014

Member Function Documentation

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 (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).
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
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)
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)
virtual void hdi::core::InternetGET::run ( )
virtual

Starts the GET request.

Author
GW
Date
07/2014
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