summaryrefslogtreecommitdiffstats
path: root/storage/maria/libmarias3/src/request.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria/libmarias3/src/request.c')
-rw-r--r--storage/maria/libmarias3/src/request.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/storage/maria/libmarias3/src/request.c b/storage/maria/libmarias3/src/request.c
index 26165474..b2924f9d 100644
--- a/storage/maria/libmarias3/src/request.c
+++ b/storage/maria/libmarias3/src/request.c
@@ -413,7 +413,7 @@ static uint8_t build_request_headers(CURL *curl, struct curl_slist **head,
time_t now;
struct tm tmp_tm;
char headerbuf[3072];
- char secrethead[45];
+ char secrethead[MAX_S3_SECRET_LENGTH + S3_SECRET_EXTRA_LENGTH];
char date[9];
char sha256hash[65];
char post_hash[65];
@@ -520,7 +520,7 @@ static uint8_t build_request_headers(CURL *curl, struct curl_slist **head,
// User signing key hash
// Date hashed using AWS4:secret_key
- snprintf(secrethead, sizeof(secrethead), "AWS4%.*s", 40, secret);
+ snprintf(secrethead, sizeof(secrethead), "AWS4%.*s", MAX_S3_SECRET_LENGTH, secret);
strftime(headerbuf, sizeof(headerbuf), "%Y%m%d", &tmp_tm);
hmac_sha256((uint8_t *)secrethead, strlen(secrethead), (uint8_t *)headerbuf,
strlen(headerbuf), hmac_hash);
@@ -829,9 +829,19 @@ uint8_t execute_request(ms3_st *ms3, command_t cmd, const char *bucket,
if (ms3->port)
curl_easy_setopt(curl, CURLOPT_PORT, (long)ms3->port);
+ if (ms3->read_cb && cmd == MS3_CMD_GET)
+ {
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ms3->read_cb);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, ms3->user_data);
+ }
+ else
+ {
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, body_callback);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&mem);
+ }
+
+ curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, ms3->buffer_chunk_size);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, body_callback);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&mem);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_res = curl_easy_perform(curl);
@@ -848,6 +858,18 @@ uint8_t execute_request(ms3_st *ms3, command_t cmd, const char *bucket,
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
ms3debug("Response code: %ld", response_code);
+ if (response_code == 301)
+ {
+ char *message = parse_error_message((char *)mem.data, mem.length);
+
+ if (message)
+ {
+ ms3debug("Response message: %s", message);
+ }
+
+ set_error_nocopy(ms3, message);
+ res = MS3_ERR_ENDPOINT;
+ }
if (response_code == 404)
{
char *message = parse_error_message((char *)mem.data, mem.length);