Only set one of HTTPGET, UPLOAD, POST or NOBODY curl options #280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #259
While s3.c: perform_request() is called with verb="PUT" libcurl sends a GET request.
Since the method of the call is part of the S3 authorization hashing, the hashes do not match causing a Signature Error.
libcurl's documentation says that a PUT will be done if the CURLOPT_UPLOAD, CURLOPT_READFUNCTION, and CURLOPT_READDATA are all set.
What the documentation does not say is that only one of CURLOPT_HTTPGET, CURLOPT_UPLOAD, CURLOPT_POST, or CURLOPT_NOBODY can be set. In our case, we set CURLOPT_UPLOAD correctly and then set POST and NOBODY (to zero).
This appears to reset the options to "none" which defaults to "GET" causing the GET instead of PUT.
Using C's shortcut feture on conditionals, we check if the option should be set before we set the option.