ofURLFileLoader
This class provides several convenient methods for making HTTP requests.
ofHttpResponse resp = ofLoadURL("http://www.google.com/robots.txt");
cout << resp.data << endl;
clear( )
void clear()clear all active HTTP requests from the queue
get( ... )
ofHttpResponse get(const string &url)make an HTTP request blocks until a response is returned or the request times out
Parameters:
url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg" \return HTTP response on success or failure
getAsync( ... )
int getAsync(const string &url, const string &name)make an asynchronous HTTP request will not block, placed in a queue and run using a background thread
Parameters:
url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
name optional key to use when sorting requests \return unique id for the active HTTP request
handleRequest( ... )
ofHttpResponse handleRequest(const ofHttpRequest &request)blocks until a response is returned or the request times out \return HTTP response on success or failure
handleRequestAsync( ... )
int handleRequestAsync(const ofHttpRequest &request)this is a non-blocking version of handleRequest that will return a response in the urlResponse callback \return unique id of the active HTTP request
ofURLFileLoader( )
ofURLFileLoader()remove( ... )
void remove(int id)remove an active HTTP request from the queue
Parameters:
unique HTTP request id
saveAsync( ... )
int saveAsync(const string &url, const filesystem::path &path)make an asynchronous HTTP request and save the response data to a file will not block, placed in a queue and run using a background thread
Parameters:
url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
path file path to save to
Returns: unique id for the active HTTP request
saveTo( ... )
ofHttpResponse saveTo(const string &url, const filesystem::path &path)make an HTTP request and save the response data to a file blocks until a response is returned or the request times out
Parameters:
url HTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
path file path to save to \return HTTP response on success or failure
stop( )
void stop()stop & remove all active and waiting HTTP requests