Page tree
Skip to end of metadata
Go to start of metadata

public static FB::SimpleStreamHelperPtr FB::SimpleStreamHelper::AsyncGet ( const FB::BrowserHostPtr host,
const FB::URI uri,
const HttpCallback &  callback,
bool  cache = true,
size_t  bufferSize = 128*1024 

Starts an asynchronous HTTP get request.

Call this static method to make an asyncronous HTTP get request through the browser. Note that you can hold onto the ptr to the request but you don't have to – it will be cleaned up automatically when the request finishes.

void FBTestPluginAPI::getURL(const std::string& url, const FB::JSObjectPtr& callback)
boost::bind(&FBTestPluginAPI::getURLCallback, this, callback, _1, _2, _3, _4));
void FBTestPluginAPI::getURLCallback(const FB::JSObjectPtr& callback, bool success,
const FB::HeaderMap& headers, const boost::shared_array<uint8_t>& data, const size_t size) {
if (success) {
std::string dstr(reinterpret_cast<const char*>(data.get()), size);
// Do something here; dstr is a string containing the full body
// headers is a multimap with all the headers
} else {
// The request could not be completed
hostconst FB::BrowserHostPtr& BrowserHostPtr to use to create the stream
uriconst FB::URI& URI to request
callbackconst HttpCallback & Function to call with the response
cacheconst bool true if cache can be used
bufferSizeconst size_t Specifies the size of the buffer to use internally
See Also
1.7 use AsyncRequest

Definition at line 26 of file SimpleStreamHelper.cpp.

References AsyncRequest(), FB::BrowserStreamRequest::setBufferSize(), FB::BrowserStreamRequest::setCacheable(), and FB::BrowserStreamRequest::setCallback().

28 {
29  BrowserStreamRequest req(uri, "GET");
30  req.setCallback(callback);
31  req.setBufferSize(bufferSize);
32  req.setCacheable(cache);
33  return AsyncRequest(host, req);
34 }
static FB::SimpleStreamHelperPtr AsyncRequest(const BrowserHostConstPtr &host, const BrowserStreamRequest &req)
Creates an asynchronous HTTP request from the provided BrowserStreamRequest.

Here is the call graph for this function:

  • No labels