Merge lp://staging/~gary-wzl77/net-cpp/bug-fixing-and-features into lp://staging/net-cpp

Proposed by Gary.Wang
Status: Merged
Merged at revision: 50
Proposed branch: lp://staging/~gary-wzl77/net-cpp/bug-fixing-and-features
Merge into: lp://staging/net-cpp
Diff against target: 804 lines (+407/-9)
14 files modified
CMakeLists.txt (+2/-2)
include/core/net/http/client.h (+19/-0)
include/core/net/http/method.h (+3/-1)
include/core/net/http/request.h (+21/-0)
include/core/net/http/streaming_client.h (+21/-1)
include/core/net/http/streaming_request.h (+13/-0)
src/core/net/http/impl/curl/client.cpp (+82/-2)
src/core/net/http/impl/curl/client.h (+7/-0)
src/core/net/http/impl/curl/easy.cpp (+23/-0)
src/core/net/http/impl/curl/easy.h (+14/-1)
src/core/net/http/impl/curl/request.h (+33/-0)
tests/http_client_test.cpp (+73/-0)
tests/http_streaming_client_test.cpp (+90/-2)
tests/httpbin.h.in (+6/-0)
To merge this branch: bzr merge lp://staging/~gary-wzl77/net-cpp/bug-fixing-and-features
Reviewer Review Type Date Requested Status
Thomas Voß (community) Approve
Review via email: mp+291975@code.staging.launchpad.net

Commit message

1.Fix crash issue when sending large chunk data via PUT method (lp:1570686)
3.Support DELETE method (lp:1570687)
2.Support POST method with istream
4.Support pause and resume mechanism
5.Add some test cases

Description of the change

1.Fix crash issue when sending large chunk data via PUT method (lp:1570686)
3.Support DELETE method (lp:1570687)
2.Support POST method with istream
4.Support pause and resume mechanism
5.Add some test cases

To post a comment you must log in.
Revision history for this message
Thomas Voß (thomas-voss) wrote :

Thanks for the changes, looking good. A few minor niggles inline,

review: Needs Fixing
51. By Gary.Wang

1.bump major revision since this change breaks ABI
2.introduce new API (abort_request_option) for request
3.fix typo

52. By Gary.Wang

1.abort_request_option -> abort_request_if to make api more self-explanatory
2.do not set abort request option by default

Revision history for this message
Thomas Voß (thomas-voss) wrote :

Thanks for your changes, the MP looks good to me. I tried to further understand your remarks about only setting abort_request_option if explicitly requested and read up on: https://curl.haxx.se/libcurl/c/curl_easy_pause.html. I do not see an issue in the case of async requests, though. For synchronous requests, the operation might block indefinitely, and we should at least document the respective error mode.

Hope that addresses your remark :) Or did I miss something?

review: Approve
Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Thanks, Please add the following test case in http_streaming_client_test.cpp.
http://bazaar.launchpad.net/~gary-wzl77/+junk/net-cpp_test_pause_and_resume/revision/53/tests/http_streaming_client_test.cpp#tests/=

Then we can see the potential issue we have in this MP after it is run. (I use the async api to reproduce this issue.)

Log:
....
Download progress: 0.0154666
Download progress: 0.0154666
we pause
Download progress: 0.0154666
Download progress: 0.0154666
Download progress: 0.0154666
we resume.

I resume download after the request is paused for 5 secs. But there is no "Download progress" log printing out any more even if I resume it. It causes the curl thread to hang as well. The issue can be reproduces 100%.

However if I explicitly set async_abort_if(1k/s, 10s) before request asynchronous execution(async_execute). Everything works fine.

Log:
Download progress: 0.0077333
Download progress: 0.0077333
Download progress: 0.0077333
we pause
Download progress: 0.0077333
we resume.
Download progress: 0.0077333
Download progress: 0.0077333
Download progress: 0.0077333
Download progress: 0.00883806
Download progress: 0.00883806

So it's better to mention this case in doc somewhere to reminder developer of setting abort_request_option explicitly before request asynchronous execution if they really want to pause/resume a request in one connection.
Otherwise developer doesn't figure out why it doesn't work out after resuming from paused state.
But anyway, it works fine if developers don't use pause/resume API.

P.S:
curl utilizes progress callback(CURLOPT_PROGRESSFUNCTION) to set bitmask(CURLPAUSE_CONT/CURLPAUSE_ALL) for a connection state change(pause/resume). However the default value of speed_time(2nd argument for abort_request_if) is 0(disabled). So after request is paused, progress cb gets no chance to call in such a case. It failed to resume even if we set the bitmask(CURLPAUSE_CONT).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: