reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofURLFileLoader Class Reference

loads a file from a URL using an HTTP request More...

#include <ofURLFileLoader.h>

Public Member Functions

 ofURLFileLoader ()
 
ofHttpResponse get (const std::string &url)
 make an HTTP request blocks until a response is returned or the request times out
 
int getAsync (const std::string &url, const std::string &name="")
 make an asynchronous HTTP request will not block, placed in a queue and run using a background thread
 
ofHttpResponse saveTo (const std::string &url, const of::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
 
int saveAsync (const std::string &url, const of::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
 
void remove (int id)
 remove an active HTTP request from the queue
 
void clear ()
 clear all active HTTP requests from the queue
 
void stop ()
 stop & remove all active and waiting HTTP requests
 
ofHttpResponse handleRequest (const ofHttpRequest &request)
 
int handleRequestAsync (const ofHttpRequest &request)
 

Detailed Description

loads a file from a URL using an HTTP request

Constructor & Destructor Documentation

◆ ofURLFileLoader()

ofURLFileLoader::ofURLFileLoader ( )

Member Function Documentation

◆ clear()

void ofURLFileLoader::clear ( )

clear all active HTTP requests from the queue

◆ get()

ofHttpResponse ofURLFileLoader::get ( const std::string &  url)

make an HTTP request blocks until a response is returned or the request times out

Parameters
urlHTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
Returns
HTTP response on success or failure

◆ getAsync()

int ofURLFileLoader::getAsync ( const std::string &  url,
const std::string &  name = "" 
)

make an asynchronous HTTP request will not block, placed in a queue and run using a background thread

Parameters
urlHTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
nameoptional key to use when sorting requests
Returns
unique id for the active HTTP request

◆ handleRequest()

ofHttpResponse ofURLFileLoader::handleRequest ( const ofHttpRequest request)

blocks until a response is returned or the request times out

Returns
HTTP response on success or failure

◆ handleRequestAsync()

int ofURLFileLoader::handleRequestAsync ( const ofHttpRequest request)

this is a non-blocking version of handleRequest that will return a response in the urlResponse callback

Returns
unique id of the active HTTP request

◆ remove()

void ofURLFileLoader::remove ( int  id)

remove an active HTTP request from the queue

Parameters
idHTTP request id

◆ saveAsync()

int ofURLFileLoader::saveAsync ( const std::string &  url,
const of::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
urlHTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
pathfile path to save to
Returns
unique id for the active HTTP request

◆ saveTo()

ofHttpResponse ofURLFileLoader::saveTo ( const std::string &  url,
const of::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
urlHTTP url to request, ie. "http://somewebsite.com/someapi/someimage.jpg"
pathfile path to save to
Returns
HTTP response on success or failure

◆ stop()

void ofURLFileLoader::stop ( )

stop & remove all active and waiting HTTP requests


The documentation for this class was generated from the following files: