FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
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 
)
static

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
}
}
Parameters
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
Returns
FB::SimpleStreamHelperPtr
Since
1.4b3
See Also
SynchronousGet
FB::URI
Deprecated:
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: