Skip to content

Progress callback for async read / write and some smaller fixes

Stefan Woe requested to merge StefanWoe/Simple-Web-Server:master into master

As described in Issue #348 i added a progress callback for asnc http/https calls. This new callback can be used i.e. as follows:

typedef typename SimpleWeb::Client<server_type_tag>::progress_data_type  progress_type;
std::function<void(progress_type &)> progress_callback = 
    [clientp]
    (progress_type& progress) 
{
    some_application_data->bytes_total       = progress.bytes_total;
    some_application_data->bytes_transmitted = progress.bytes_transmitted;
    some_application_data->sendingData = progress.mode == progress_type::SEND_DATA;
    if(some_application_data->doCancel)
        clientp->io_service->stop();                
};
clientPtr->request(request_method, in_path, content, header, response_callback, progress_callback);

This has been successfully tested on Mac and Windows.

There are 3 more commits in this request:

  • use #define for PROGRESS_CHUNK_SIZE This is just a workaround for llvm not accepting a static const int class member without again defining it in a source file. Could be done better.

  • socket->set_verify_mode(boost::asio::ssl::verify_none); This was necessary for our services - i cant tell if this is a good approach in general.

  • Application Crash if no network present We found that a laptop that currently has no network connection at all crashes when trying to call a http/https service. This mainly happened on the mac but also was reproducible upon Windows. It seems to be a boost problem which i posted, but never got an answer: https://sourceforge.net/p/boost/discussion/127795/thread/a9592f3793/ The code is rather a hack but it solved the problem for us.

Merge request reports