aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-01-23 12:45:51 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-01-23 13:08:19 +0200
commit0ed8a2275a3a6cda553b82e9e0222b9d3b8b3ff2 (patch)
tree2b617611ddeb6f97d9f316750496ac13c5ce59ad /src/util.c
parentb1824338b366e25756e4c64f04e535684529832d (diff)
downloadeclat-0ed8a2275a3a6cda553b82e9e0222b9d3b8b3ff2.tar.gz
eclat-0ed8a2275a3a6cda553b82e9e0222b9d3b8b3ff2.tar.bz2
Implement HTTP POST
* NEWS: Update. * doc/eclat.conf.5: Document http-method. Reorganize description of endpoints and regions. * lib/libeclat.h (ec2_request) <postdata>: New member (eclat_request_finalize): New proto. * lib/req2url.c (eclat_request_to_url): Remove second argument. All uses changed. (eclat_request_finalize): New function. * lib/reqfree.c: Free postdata. * lib/reqsign.c (requestsign4): Implement post. * src/config.c: New configuration statement http-method. * src/eclat.c (use_post): New variable. * src/eclat.h (use_post): New extern. * src/util.c (eclat_send_request): Implement post.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 92532f0..79a78ff 100644
--- a/src/util.c
+++ b/src/util.c
@@ -227,8 +227,15 @@ eclat_send_request(CURL *curl, struct ec2_request *req)
struct curl_slist *headers = NULL;
/* Prepare the request */
+ if (req->flags & EC2_RF_POST) {
+ eclat_request_finalize(req);
+ curl_easy_setopt(curl, CURLOPT_POST, 1);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, req->postdata);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
+ strlen(req->postdata));
+ }
eclat_request_sign(req, secret_key, signature_version);
- url = eclat_request_to_url(req, NULL);
+ url = eclat_request_to_url(req);
curl_easy_setopt(curl, CURLOPT_URL, url);
debug(ECLAT_DEBCAT_MAIN, 1, ("using URL: %s", url));
free(url);
@@ -263,6 +270,9 @@ eclat_send_request(CURL *curl, struct ec2_request *req)
curl_easy_strerror(rc));
}
+ if (req->flags & EC2_RF_POST)
+ debug(ECLAT_DEBCAT_MAIN, 1, ("DATA: %s", req->postdata));
+
if (dry_run_mode)
debug(ECLAT_DEBCAT_MAIN, 1, ("not sending request"));
else {

Return to:

Send suggestions and report system problems to the System administrator.