Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added progress to POST, PUT, PATCH and DELETE requests #1821

Merged
merged 3 commits into from
Apr 21, 2024

Conversation

rndm13
Copy link
Contributor

@rndm13 rndm13 commented Apr 18, 2024

Added multiple methods to Client and ClientImpl classes that accept progress callback for POST, PUT, PATCH and DELETE.
Needed to have a functionality for user to cancel their requests and these changes add that.
Main change is in send_with_content_provider which now also accepts Progress. Other changes are mostly boilerplate functions additions.
Fixes #1330 issue as well

@yhirose
Copy link
Owner

yhirose commented Apr 18, 2024

@rndm13, thanks for the pull request. Could you please add unit tests for the new methods?

@yhirose yhirose merged commit 2bc550b into yhirose:master Apr 21, 2024
4 checks passed
@yhirose
Copy link
Owner

yhirose commented Apr 21, 2024

@rndm13, thanks for the contribution!

@kunlinyu
Copy link

@rndm13 HI, I am using this feature for "PUT"

httplib::Client cli(domain);
auto res = cli.Put(
    path_with_params, {}, buffer.data(), bytes_read,
    "application/octet-stream", [&](uint64_t current, uint64_t total) {
      std::cout << "current/total: " << current << "/" << total << std::endl;
      return true;
    });

But even if I put a big file more then 10MB, the progress will always be "current/total: 16/16".
Then I check the code. I notice that the "read_content_with_length()" will call the progress lambda.

So I want to ask, is it about the progress of the file I put to the server, or the progress about the response?

@rndm13
Copy link
Contributor Author

rndm13 commented May 31, 2024

@kunlinyu Hello, from what I understand the progress does indeed give you information about server response, not about your client request.
Maybe it would be best to rename Progress to ResponseProgress to avoid this kind of confusion?

@kunlinyu
Copy link

@rndm13 Thank you! I think you are right.
Accually the first time when I saw the name "progress", I thought it is response progress for GET and request progress for PUT and POST. It is very good to rename it ResponseProgress. And furthur more, I think we need both RequestProgress and ResponseProgress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

httplib::Progress for Post requests?
3 participants