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

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

Starts an asynchronous HTTP post request.

Call this static method to make an asyncronous HTTP post 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::postURL(const std::string& url, const std::string& postdata, concst 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
postdataconst std::string& Post data to send
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 36 of file SimpleStreamHelper.cpp.

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

42 {
43  BrowserStreamRequest req(uri, "POST");
44  req.setPostData(postdata);
45  req.setCallback(callback);
46  req.setBufferSize(bufferSize);
47  req.setCacheable(cache);
48  return AsyncRequest(host, req);
49 }
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