~gary-wzl77/net-cpp/bug-fixing-and-features

« back to all changes in this revision

Viewing changes to src/core/net/http/impl/curl/request.h

  • Committer: Gary.Wang
  • Date: 2016-05-17 12:02:18 UTC
  • Revision ID: gary.wang@canonical.com-20160517120218-rvyuhp1cm61yyii6
1.bump major revision since this change breaks ABI
2.introduce new API (abort_request_option) for request
3.fix typo

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
          multi(multi),
99
99
          easy(easy)
100
100
    {
 
101
        //Make it possible to get a chance to run on_progress call back function when pause() is called. 
 
102
        //Otherwise progress call back function will not be invoked, which causes threads doesn't get notified
 
103
        //after the proper magic return code even if resume() is called.
 
104
        abort_request_option(::curl::easy::low_speed_limit, ::curl::easy::low_speed_time);
101
105
    }
102
106
 
103
107
    State state()
305
309
    {
306
310
        return easy.unescape(s);
307
311
    }
 
312
 
 
313
    void abort_request_option(long speed_limit, long speed_time)
 
314
    {
 
315
        if (atomic_state.load() != core::net::http::Request::State::ready)
 
316
            throw core::net::http::Request::Errors::AlreadyActive{CORE_FROM_HERE()};
 
317
    
 
318
        easy.set_option(::curl::Option::low_speed_limit, speed_limit);
 
319
        easy.set_option(::curl::Option::low_speed_time, speed_time);
 
320
    }
 
321
 
308
322
private:
309
323
    std::atomic<core::net::http::Request::State> atomic_state;
310
324
    ::curl::multi::Handle multi;