Skip to content

Conversation

@clarkok
Copy link
Contributor

@clarkok clarkok commented Nov 10, 2025

Add most Post overloads for Client, with both content provider and content receiver.

  • Result Post(const std::string &path, size_t content_length, ContentProvider content_provider, const std::string &content_type, ContentReceiver content_receiver, UploadProgress progress = nullptr)
  • Result Post(const std::string &path, ContentProviderWithoutLength content_provider, const std::string &content_type, ContentReceiver content_receiver, UploadProgress progress = nullptr)
  • Result Post(const std::string &path, const Headers &headers, size_t content_length, ContentProvider content_provider, const std::string &content_type, ContentReceiver content_receiver, DownloadProgress progress = nullptr)
  • Result Post(const std::string &path, const Headers &headers, ContentProviderWithoutLength content_provider, const std::string &content_type, ContentReceiver content_receiver, DownloadProgress progress = nullptr)

@yhirose
Copy link
Owner

yhirose commented Nov 10, 2025

@clarkok thanks for the pull request. But I am not going to approve it since it create another two POST specific implementations. Could you please rename send_with_content_provider to send_with_content_provider_and_receiver, and add your receiver support to it? Also could you add the same methods to PUT and PATCH for consistency? Then, I'll start review your pull request. Thanks!

@clarkok
Copy link
Contributor Author

clarkok commented Nov 12, 2025

Thanks @yhirose . I've done the changes you mentioned. Would you mind taking a look?

@clarkok clarkok changed the title Add Client::Post with both content provider and receiver Add Client methods with both content provider and receiver Nov 13, 2025
httplib.h Outdated

// Allocate on the heap, so the resolver thread can keep using the data.
auto state = std::make_shared<GetAddrInfoState>();
state->node = node;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why these lines need to be added? These are already added at line 3842 and 3843.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was not planning to take this change in the PR, I'm not very familar with how PR works in Github.

However this is a separated issue I found during my Android project. In short, this doesn't work, the node on the right side of the assignment is actually referring to the member of GetAddrInforState which is empty, instead of the function parameter. Thus the getaddrinfo below always return EAI_SERVICE as both node and service are empty, and probably hints are not in expected state.

I've written a short piece of repro code in the below link for your reference.

https://godbolt.org/z/9sW9EjjYK

I'll revert this back and create a new PR for the issue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP, BTW after this fix the library is working on Android flawlessly

@yhirose yhirose merged commit 5988275 into yhirose:master Nov 14, 2025
9 of 23 checks passed
@yhirose
Copy link
Owner

yhirose commented Nov 14, 2025

@clarkok Thanks for the excellent contribution!

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.

2 participants