From 1b4b3538cc218f66ed1e903c3caeade4b0ab1120 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 19 Feb 2021 08:22:50 -0500 Subject: [PATCH] Rename uri to path where appropriate in HTTP and storage modules. The path was originally named uri due to the canonicalized path being called "canonicalized uri" in the S3 authentication documentation. The name got propagated everywhere from there. This is not correct for general usage, however, so rename to path when describing the path component of an HTTP request. --- src/common/io/http/request.c | 22 +++++++++---------- src/common/io/http/request.h | 10 ++++----- src/storage/azure/read.c | 2 +- src/storage/azure/storage.c | 30 ++++++++++++------------- src/storage/azure/storage.intern.h | 6 ++--- src/storage/azure/write.c | 6 ++--- src/storage/s3/storage.c | 32 +++++++++++++-------------- src/storage/s3/storage.intern.h | 12 +++++----- test/src/module/common/ioHttpTest.c | 6 ++--- test/src/module/storage/azureTest.c | 28 ++++++++++++------------ test/src/module/storage/s3Test.c | 34 ++++++++++++++--------------- 11 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/common/io/http/request.c b/src/common/io/http/request.c index 8e2c1638b..70150a142 100644 --- a/src/common/io/http/request.c +++ b/src/common/io/http/request.c @@ -44,7 +44,7 @@ struct HttpRequest MemContext *memContext; // Mem context HttpClient *client; // HTTP client const String *verb; // HTTP verb (GET, POST, etc.) - const String *uri; // HTTP URI + const String *path; // HTTP path const HttpQuery *query; // HTTP query const HttpHeader *header; // HTTP headers const Buffer *content; // HTTP content @@ -56,7 +56,7 @@ OBJECT_DEFINE_MOVE(HTTP_REQUEST); OBJECT_DEFINE_FREE(HTTP_REQUEST); OBJECT_DEFINE_GET(Verb, const, HTTP_REQUEST, const String *, verb); -OBJECT_DEFINE_GET(Uri, const, HTTP_REQUEST, const String *, uri); +OBJECT_DEFINE_GET(Path, const, HTTP_REQUEST, const String *, path); OBJECT_DEFINE_GET(Query, const, HTTP_REQUEST, const HttpQuery *, query); OBJECT_DEFINE_GET(Header, const, HTTP_REQUEST, const HttpHeader *, header); @@ -108,7 +108,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache) String *requestStr = strNewFmt( "%s %s%s%s " HTTP_VERSION CRLF_Z HTTP_HEADER_USER_AGENT ":" PROJECT_NAME "/" PROJECT_VERSION CRLF_Z, - strZ(this->verb), strZ(httpUriEncode(this->uri, true)), this->query == NULL ? "" : "?", + strZ(this->verb), strZ(httpUriEncode(this->path, true)), this->query == NULL ? "" : "?", this->query == NULL ? "" : strZ(httpQueryRenderP(this->query))); // Add headers @@ -181,19 +181,19 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache) /**********************************************************************************************************************************/ HttpRequest * -httpRequestNew(HttpClient *client, const String *verb, const String *uri, HttpRequestNewParam param) +httpRequestNew(HttpClient *client, const String *verb, const String *path, HttpRequestNewParam param) { FUNCTION_LOG_BEGIN(logLevelDebug) FUNCTION_LOG_PARAM(HTTP_CLIENT, client); FUNCTION_LOG_PARAM(STRING, verb); - FUNCTION_LOG_PARAM(STRING, uri); + FUNCTION_LOG_PARAM(STRING, path); FUNCTION_LOG_PARAM(HTTP_QUERY, param.query); FUNCTION_LOG_PARAM(HTTP_HEADER, param.header); FUNCTION_LOG_PARAM(BUFFER, param.content); FUNCTION_LOG_END(); ASSERT(verb != NULL); - ASSERT(uri != NULL); + ASSERT(path != NULL); HttpRequest *this = NULL; @@ -206,7 +206,7 @@ httpRequestNew(HttpClient *client, const String *verb, const String *uri, HttpRe .memContext = MEM_CONTEXT_NEW(), .client = client, .verb = strDup(verb), - .uri = strDup(uri), + .path = strDup(path), .query = httpQueryDupP(param.query), .header = param.header == NULL ? httpHeaderNew(NULL) : httpHeaderDup(param.header, NULL), .content = param.content == NULL ? NULL : bufDup(param.content), @@ -254,10 +254,10 @@ httpRequestError(const HttpRequest *this, HttpResponse *response) if (strSize(httpResponseReason(response)) > 0) strCatFmt(error, " (%s)", strZ(httpResponseReason(response))); - // Output uri/query - strCatZ(error, ":\n*** URI/Query ***:"); + // Output path/query + strCatZ(error, ":\n*** Path/Query ***:"); - strCatFmt(error, "\n%s", strZ(httpUriEncode(this->uri, true))); + strCatFmt(error, "\n%s", strZ(httpUriEncode(this->path, true))); if (this->query != NULL) strCatFmt(error, "?%s", strZ(httpQueryRenderP(this->query, .redact = true))); @@ -309,7 +309,7 @@ String * httpRequestToLog(const HttpRequest *this) { return strNewFmt( - "{verb: %s, uri: %s, query: %s, header: %s, contentSize: %zu}", strZ(this->verb), strZ(this->uri), + "{verb: %s, path: %s, query: %s, header: %s, contentSize: %zu}", strZ(this->verb), strZ(this->path), this->query == NULL ? "null" : strZ(httpQueryToLog(this->query)), strZ(httpHeaderToLog(this->header)), this->content == NULL ? 0 : bufUsed(this->content)); } diff --git a/src/common/io/http/request.h b/src/common/io/http/request.h index ab3ffa07e..244759688 100644 --- a/src/common/io/http/request.h +++ b/src/common/io/http/request.h @@ -65,10 +65,10 @@ typedef struct HttpRequestNewParam const Buffer *content; } HttpRequestNewParam; -#define httpRequestNewP(client, verb, uri, ...) \ - httpRequestNew(client, verb, uri, (HttpRequestNewParam){VAR_PARAM_INIT, __VA_ARGS__}) +#define httpRequestNewP(client, verb, path, ...) \ + httpRequestNew(client, verb, path, (HttpRequestNewParam){VAR_PARAM_INIT, __VA_ARGS__}) -HttpRequest *httpRequestNew(HttpClient *client, const String *verb, const String *uri, HttpRequestNewParam param); +HttpRequest *httpRequestNew(HttpClient *client, const String *verb, const String *path, HttpRequestNewParam param); /*********************************************************************************************************************************** Functions @@ -88,8 +88,8 @@ Getters/Setters // Request verb const String *httpRequestVerb(const HttpRequest *this); -// Request URI -const String *httpRequestUri(const HttpRequest *this); +// Request path +const String *httpRequestPath(const HttpRequest *this); // Request query const HttpQuery *httpRequestQuery(const HttpRequest *this); diff --git a/src/storage/azure/read.c b/src/storage/azure/read.c index 44663b99f..1dccb054d 100644 --- a/src/storage/azure/read.c +++ b/src/storage/azure/read.c @@ -59,7 +59,7 @@ storageReadAzureOpen(THIS_VOID) MEM_CONTEXT_BEGIN(this->memContext) { this->httpResponse = storageAzureRequestP( - this->storage, HTTP_VERB_GET_STR, .uri = this->interface.name, .allowMissing = true, .contentIo = true); + this->storage, HTTP_VERB_GET_STR, .path = this->interface.name, .allowMissing = true, .contentIo = true); } MEM_CONTEXT_END(); diff --git a/src/storage/azure/storage.c b/src/storage/azure/storage.c index 9df7e345e..dabbe11de 100644 --- a/src/storage/azure/storage.c +++ b/src/storage/azure/storage.c @@ -75,7 +75,7 @@ struct StorageAzure const HttpQuery *sasKey; // SAS key const String *host; // Host name size_t blockSize; // Block size for multi-block upload - const String *uriPrefix; // Account/container prefix + const String *pathPrefix; // Account/container prefix uint64_t fileId; // Id to used to make file block identifiers unique }; @@ -87,12 +87,12 @@ Based on the documentation at https://docs.microsoft.com/en-us/rest/api/storages ***********************************************************************************************************************************/ static void storageAzureAuth( - StorageAzure *this, const String *verb, const String *uri, HttpQuery *query, const String *dateTime, HttpHeader *httpHeader) + StorageAzure *this, const String *verb, const String *path, HttpQuery *query, const String *dateTime, HttpHeader *httpHeader) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(STORAGE_AZURE, this); FUNCTION_TEST_PARAM(STRING, verb); - FUNCTION_TEST_PARAM(STRING, uri); + FUNCTION_TEST_PARAM(STRING, path); FUNCTION_TEST_PARAM(HTTP_QUERY, query); FUNCTION_TEST_PARAM(STRING, dateTime); FUNCTION_TEST_PARAM(KEY_VALUE, httpHeader); @@ -100,7 +100,7 @@ storageAzureAuth( ASSERT(this != NULL); ASSERT(verb != NULL); - ASSERT(uri != NULL); + ASSERT(path != NULL); ASSERT(dateTime != NULL); ASSERT(httpHeader != NULL); ASSERT(httpHeaderGet(httpHeader, HTTP_HEADER_CONTENT_LENGTH_STR) != NULL); @@ -165,10 +165,10 @@ storageAzureAuth( "\n" // If-Unmodified-Since "\n" // range "%s" // Canonicalized headers - "/%s%s" // Canonicalized account/uri + "/%s%s" // Canonicalized account/path "%s", // Canonicalized query strZ(verb), strEq(contentLength, ZERO_STR) ? "" : strZ(contentLength), contentMd5 == NULL ? "" : strZ(contentMd5), - strZ(dateTime), strZ(headerCanonical), strZ(this->account), strZ(uri), strZ(queryCanonical)); + strZ(dateTime), strZ(headerCanonical), strZ(this->account), strZ(path), strZ(queryCanonical)); // Generate authorization header Buffer *keyBin = bufNew(decodeToBinSize(encodeBase64, strZ(this->sharedKey))); @@ -201,7 +201,7 @@ storageAzureRequestAsync(StorageAzure *this, const String *verb, StorageAzureReq FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STORAGE_AZURE, this); FUNCTION_LOG_PARAM(STRING, verb); - FUNCTION_LOG_PARAM(STRING, param.uri); + FUNCTION_LOG_PARAM(STRING, param.path); FUNCTION_LOG_PARAM(HTTP_HEADER, param.header); FUNCTION_LOG_PARAM(HTTP_QUERY, param.query); FUNCTION_LOG_PARAM(BUFFER, param.content); @@ -214,8 +214,8 @@ storageAzureRequestAsync(StorageAzure *this, const String *verb, StorageAzureReq MEM_CONTEXT_TEMP_BEGIN() { - // Prepend uri prefix - param.uri = param.uri == NULL ? this->uriPrefix : strNewFmt("%s%s", strZ(this->uriPrefix), strZ(param.uri)); + // Prepend path prefix + param.path = param.path == NULL ? this->pathPrefix : strNewFmt("%s%s", strZ(this->pathPrefix), strZ(param.path)); // Create header list and add content length HttpHeader *requestHeader = param.header == NULL ? @@ -241,13 +241,13 @@ storageAzureRequestAsync(StorageAzure *this, const String *verb, StorageAzureReq httpQueryDupP(param.query, .redactList = this->queryRedactList); // Generate authorization header - storageAzureAuth(this, verb, httpUriEncode(param.uri, true), query, httpDateFromTime(time(NULL)), requestHeader); + storageAzureAuth(this, verb, httpUriEncode(param.path, true), query, httpDateFromTime(time(NULL)), requestHeader); // Send request MEM_CONTEXT_PRIOR_BEGIN() { result = httpRequestNewP( - this->httpClient, verb, param.uri, .query = query, .header = requestHeader, .content = param.content); + this->httpClient, verb, param.path, .query = query, .header = requestHeader, .content = param.content); } MEM_CONTEXT_END(); } @@ -292,7 +292,7 @@ storageAzureRequest(StorageAzure *this, const String *verb, StorageAzureRequestP FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STORAGE_AZURE, this); FUNCTION_LOG_PARAM(STRING, verb); - FUNCTION_LOG_PARAM(STRING, param.uri); + FUNCTION_LOG_PARAM(STRING, param.path); FUNCTION_LOG_PARAM(HTTP_HEADER, param.header); FUNCTION_LOG_PARAM(HTTP_QUERY, param.query); FUNCTION_LOG_PARAM(BUFFER, param.content); @@ -304,7 +304,7 @@ storageAzureRequest(StorageAzure *this, const String *verb, StorageAzureRequestP HTTP_RESPONSE, storageAzureResponseP( storageAzureRequestAsyncP( - this, verb, .uri = param.uri, .header = param.header, .query = param.query, .content = param.content), + this, verb, .path = param.path, .header = param.header, .query = param.query, .content = param.content), .allowMissing = param.allowMissing, .contentIo = param.contentIo)); } @@ -474,7 +474,7 @@ storageAzureInfo(THIS_VOID, const String *file, StorageInfoLevel level, StorageI ASSERT(file != NULL); // Attempt to get file info - HttpResponse *httpResponse = storageAzureRequestP(this, HTTP_VERB_HEAD_STR, .uri = file, .allowMissing = true); + HttpResponse *httpResponse = storageAzureRequestP(this, HTTP_VERB_HEAD_STR, .path = file, .allowMissing = true); // Does the file exist? StorageInfo result = {.level = level, .exists = httpResponseCodeOk(httpResponse)}; @@ -765,7 +765,7 @@ storageAzureNew( .account = strDup(account), .blockSize = blockSize, .host = host == NULL ? strNewFmt("%s.%s", strZ(account), strZ(endpoint)) : host, - .uriPrefix = host == NULL ? strNewFmt("/%s", strZ(container)) : strNewFmt("/%s/%s", strZ(account), strZ(container)), + .pathPrefix = host == NULL ? strNewFmt("/%s", strZ(container)) : strNewFmt("/%s/%s", strZ(account), strZ(container)), }; // Store shared key or parse sas query diff --git a/src/storage/azure/storage.intern.h b/src/storage/azure/storage.intern.h index 5a960e25d..d9309f6f8 100644 --- a/src/storage/azure/storage.intern.h +++ b/src/storage/azure/storage.intern.h @@ -29,13 +29,13 @@ Perform an Azure Request typedef struct StorageAzureRequestAsyncParam { VAR_PARAM_HEADER; - const String *uri; // Request URI + const String *path; // Request path const HttpHeader *header; // Request headers const HttpQuery *query; // Query parameters const Buffer *content; // Request content } StorageAzureRequestAsyncParam; -#define storageAzureRequestAsyncP(this, verb, ...) \ +#define storageAzureRequestAsyncP(this, verb, ...) \ storageAzureRequestAsync(this, verb, (StorageAzureRequestAsyncParam){VAR_PARAM_INIT, __VA_ARGS__}) HttpRequest *storageAzureRequestAsync(StorageAzure *this, const String *verb, StorageAzureRequestAsyncParam param); @@ -56,7 +56,7 @@ HttpResponse *storageAzureResponse(HttpRequest *request, StorageAzureResponsePar typedef struct StorageAzureRequestParam { VAR_PARAM_HEADER; - const String *uri; // Request URI + const String *path; // Request path const HttpHeader *header; // Request headers const HttpQuery *query; // Query parameters const Buffer *content; // Request content diff --git a/src/storage/azure/write.c b/src/storage/azure/write.c index cbfaba03d..ceb6a851a 100644 --- a/src/storage/azure/write.c +++ b/src/storage/azure/write.c @@ -148,7 +148,7 @@ storageWriteAzureBlockAsync(StorageWriteAzure *this) MEM_CONTEXT_BEGIN(this->memContext) { this->request = storageAzureRequestAsyncP( - this->storage, HTTP_VERB_PUT_STR, .uri = this->interface.name, .query = query, .content = this->blockBuffer); + this->storage, HTTP_VERB_PUT_STR, .path = this->interface.name, .query = query, .content = this->blockBuffer); } MEM_CONTEXT_END(); @@ -239,7 +239,7 @@ storageWriteAzureClose(THIS_VOID) // Finalize the multi-block upload storageAzureRequestP( - this->storage, HTTP_VERB_PUT_STR, .uri = this->interface.name, + this->storage, HTTP_VERB_PUT_STR, .path = this->interface.name, .query = httpQueryAdd(httpQueryNewP(), AZURE_QUERY_COMP_STR, AZURE_QUERY_VALUE_BLOCK_LIST_STR), .content = xmlDocumentBuf(blockXml)); } @@ -247,7 +247,7 @@ storageWriteAzureClose(THIS_VOID) else { storageAzureRequestP( - this->storage, HTTP_VERB_PUT_STR, .uri = this->interface.name, + this->storage, HTTP_VERB_PUT_STR, .path = this->interface.name, httpHeaderAdd(httpHeaderNew(NULL), AZURE_HEADER_BLOB_TYPE_STR, AZURE_HEADER_VALUE_BLOCK_BLOB_STR), .content = this->blockBuffer); } diff --git a/src/storage/s3/storage.c b/src/storage/s3/storage.c index 6bdb988cf..ccab3b497 100644 --- a/src/storage/s3/storage.c +++ b/src/storage/s3/storage.c @@ -74,7 +74,7 @@ Documentation for the response format is found at: https://docs.aws.amazon.com/A ***********************************************************************************************************************************/ STRING_STATIC(S3_CREDENTIAL_HOST_STR, "169.254.169.254"); #define S3_CREDENTIAL_PORT 80 -#define S3_CREDENTIAL_URI "/latest/meta-data/iam/security-credentials" +#define S3_CREDENTIAL_PATH "/latest/meta-data/iam/security-credentials" #define S3_CREDENTIAL_RENEW_SEC (5 * 60) VARIANT_STRDEF_STATIC(S3_JSON_TAG_ACCESS_KEY_ID_VAR, "AccessKeyId"); @@ -163,13 +163,13 @@ Based on the excellent documentation at http://docs.aws.amazon.com/AmazonS3/late ***********************************************************************************************************************************/ static void storageS3Auth( - StorageS3 *this, const String *verb, const String *uri, const HttpQuery *query, const String *dateTime, + StorageS3 *this, const String *verb, const String *path, const HttpQuery *query, const String *dateTime, HttpHeader *httpHeader, const String *payloadHash) { FUNCTION_TEST_BEGIN(); FUNCTION_TEST_PARAM(STORAGE_S3, this); FUNCTION_TEST_PARAM(STRING, verb); - FUNCTION_TEST_PARAM(STRING, uri); + FUNCTION_TEST_PARAM(STRING, path); FUNCTION_TEST_PARAM(HTTP_QUERY, query); FUNCTION_TEST_PARAM(STRING, dateTime); FUNCTION_TEST_PARAM(KEY_VALUE, httpHeader); @@ -177,7 +177,7 @@ storageS3Auth( FUNCTION_TEST_END(); ASSERT(verb != NULL); - ASSERT(uri != NULL); + ASSERT(path != NULL); ASSERT(dateTime != NULL); ASSERT(httpHeader != NULL); ASSERT(payloadHash != NULL); @@ -200,7 +200,7 @@ storageS3Auth( String *signedHeaders = NULL; String *canonicalRequest = strNewFmt( - "%s\n%s\n%s\n", strZ(verb), strZ(uri), query == NULL ? "" : strZ(httpQueryRenderP(query))); + "%s\n%s\n%s\n", strZ(verb), strZ(path), query == NULL ? "" : strZ(httpQueryRenderP(query))); for (unsigned int headerIdx = 0; headerIdx < strLstSize(headerList); headerIdx++) { @@ -278,19 +278,19 @@ storageS3CvtTime(const String *time) } HttpRequest * -storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, StorageS3RequestAsyncParam param) +storageS3RequestAsync(StorageS3 *this, const String *verb, const String *path, StorageS3RequestAsyncParam param) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STORAGE_S3, this); FUNCTION_LOG_PARAM(STRING, verb); - FUNCTION_LOG_PARAM(STRING, uri); + FUNCTION_LOG_PARAM(STRING, path); FUNCTION_LOG_PARAM(HTTP_QUERY, param.query); FUNCTION_LOG_PARAM(BUFFER, param.content); FUNCTION_LOG_END(); ASSERT(this != NULL); ASSERT(verb != NULL); - ASSERT(uri != NULL); + ASSERT(path != NULL); HttpRequest *result = NULL; @@ -313,7 +313,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St // When using path-style URIs the bucket name needs to be prepended if (this->uriStyle == storageS3UriStylePath) - uri = strNewFmt("/%s%s", strZ(this->bucket), strZ(uri)); + path = strNewFmt("/%s%s", strZ(this->bucket), strZ(path)); // If temp crendentials will be expiring soon then renew them if (this->keyType == storageS3KeyTypeAuto && (this->credExpirationTime - time(NULL)) < S3_CREDENTIAL_RENEW_SEC) @@ -328,7 +328,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St { // Request the role HttpRequest *request = httpRequestNewP( - this->credHttpClient, HTTP_VERB_GET_STR, STRDEF(S3_CREDENTIAL_URI), .header = credHeader); + this->credHttpClient, HTTP_VERB_GET_STR, STRDEF(S3_CREDENTIAL_PATH), .header = credHeader); HttpResponse *response = httpRequestResponse(request, true); // Not found likely means no role is associated with this instance @@ -353,7 +353,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St // Retrieve the temp credentials HttpRequest *request = httpRequestNewP( - this->credHttpClient, HTTP_VERB_GET_STR, strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(this->credRole)), + this->credHttpClient, HTTP_VERB_GET_STR, strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(this->credRole)), .header = credHeader); HttpResponse *response = httpRequestResponse(request, true); @@ -409,7 +409,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St // Generate authorization header storageS3Auth( - this, verb, httpUriEncode(uri, true), param.query, storageS3DateTime(time(NULL)), requestHeader, + this, verb, httpUriEncode(path, true), param.query, storageS3DateTime(time(NULL)), requestHeader, param.content == NULL || bufEmpty(param.content) ? HASH_TYPE_SHA256_ZERO_STR : bufHex(cryptoHashOne(HASH_TYPE_SHA256_STR, param.content))); @@ -417,7 +417,7 @@ storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, St MEM_CONTEXT_PRIOR_BEGIN() { result = httpRequestNewP( - this->httpClient, verb, uri, .query = param.query, .header = requestHeader, .content = param.content); + this->httpClient, verb, path, .query = param.query, .header = requestHeader, .content = param.content); } MEM_CONTEXT_END(); } @@ -457,12 +457,12 @@ storageS3Response(HttpRequest *request, StorageS3ResponseParam param) } HttpResponse * -storageS3Request(StorageS3 *this, const String *verb, const String *uri, StorageS3RequestParam param) +storageS3Request(StorageS3 *this, const String *verb, const String *path, StorageS3RequestParam param) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STORAGE_S3, this); FUNCTION_LOG_PARAM(STRING, verb); - FUNCTION_LOG_PARAM(STRING, uri); + FUNCTION_LOG_PARAM(STRING, path); FUNCTION_LOG_PARAM(HTTP_QUERY, param.query); FUNCTION_LOG_PARAM(BUFFER, param.content); FUNCTION_LOG_PARAM(BOOL, param.allowMissing); @@ -472,7 +472,7 @@ storageS3Request(StorageS3 *this, const String *verb, const String *uri, Storage FUNCTION_LOG_RETURN( HTTP_RESPONSE, storageS3ResponseP( - storageS3RequestAsyncP(this, verb, uri, .query = param.query, .content = param.content), + storageS3RequestAsyncP(this, verb, path, .query = param.query, .content = param.content), .allowMissing = param.allowMissing, .contentIo = param.contentIo)); } diff --git a/src/storage/s3/storage.intern.h b/src/storage/s3/storage.intern.h index a9edcf449..8d3e853c4 100644 --- a/src/storage/s3/storage.intern.h +++ b/src/storage/s3/storage.intern.h @@ -23,10 +23,10 @@ typedef struct StorageS3RequestAsyncParam const Buffer *content; // Request content } StorageS3RequestAsyncParam; -#define storageS3RequestAsyncP(this, verb, uri, ...) \ - storageS3RequestAsync(this, verb, uri, (StorageS3RequestAsyncParam){VAR_PARAM_INIT, __VA_ARGS__}) +#define storageS3RequestAsyncP(this, verb, path, ...) \ + storageS3RequestAsync(this, verb, path, (StorageS3RequestAsyncParam){VAR_PARAM_INIT, __VA_ARGS__}) -HttpRequest *storageS3RequestAsync(StorageS3 *this, const String *verb, const String *uri, StorageS3RequestAsyncParam param); +HttpRequest *storageS3RequestAsync(StorageS3 *this, const String *verb, const String *path, StorageS3RequestAsyncParam param); // Get async response typedef struct StorageS3ResponseParam @@ -51,10 +51,10 @@ typedef struct StorageS3RequestParam bool contentIo; // Is IoRead interface required to read content? } StorageS3RequestParam; -#define storageS3RequestP(this, verb, uri, ...) \ - storageS3Request(this, verb, uri, (StorageS3RequestParam){VAR_PARAM_INIT, __VA_ARGS__}) +#define storageS3RequestP(this, verb, path, ...) \ + storageS3Request(this, verb, path, (StorageS3RequestParam){VAR_PARAM_INIT, __VA_ARGS__}) -HttpResponse *storageS3Request(StorageS3 *this, const String *verb, const String *uri, StorageS3RequestParam param); +HttpResponse *storageS3Request(StorageS3 *this, const String *verb, const String *path, StorageS3RequestParam param); /*********************************************************************************************************************************** Macros for function logging diff --git a/test/src/module/common/ioHttpTest.c b/test/src/module/common/ioHttpTest.c index a486d0057..ec0ac754e 100644 --- a/test/src/module/common/ioHttpTest.c +++ b/test/src/module/common/ioHttpTest.c @@ -392,7 +392,7 @@ testRun(void) MEM_CONTEXT_TEMP_END(); TEST_RESULT_STR_Z(httpRequestVerb(request), "GET", "check request verb"); - TEST_RESULT_STR_Z(httpRequestUri(request), "/", "check request uri"); + TEST_RESULT_STR_Z(httpRequestPath(request), "/", "check request path"); TEST_RESULT_STR_Z( httpQueryRenderP(httpRequestQuery(request)), "name=%2Fpath%2FA%20Z.txt&type=test", "check request query"); TEST_RESULT_PTR_NE(httpRequestHeader(request), NULL, "check request headers"); @@ -489,7 +489,7 @@ testRun(void) TEST_ERROR( httpRequestError(request, response), ProtocolError, "HTTP request failed with 404 (Not Found):\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/"); // ----------------------------------------------------------------------------------------------------------------- @@ -520,7 +520,7 @@ testRun(void) TEST_ERROR( httpRequestError(request, response), ProtocolError, "HTTP request failed with 403:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/?a=b\n" "*** Request Headers ***:\n" "hdr1: 1\n" diff --git a/test/src/module/storage/azureTest.c b/test/src/module/storage/azureTest.c index 97994ad2d..8fe806b87 100644 --- a/test/src/module/storage/azureTest.c +++ b/test/src/module/storage/azureTest.c @@ -33,11 +33,11 @@ typedef struct TestRequestParam const char *blobType; } TestRequestParam; -#define testRequestP(write, verb, uri, ...) \ - testRequest(write, verb, uri, (TestRequestParam){VAR_PARAM_INIT, __VA_ARGS__}) +#define testRequestP(write, verb, path, ...) \ + testRequest(write, verb, path, (TestRequestParam){VAR_PARAM_INIT, __VA_ARGS__}) static void -testRequest(IoWrite *write, const char *verb, const char *uri, TestRequestParam param) +testRequest(IoWrite *write, const char *verb, const char *path, TestRequestParam param) { String *request = strNewFmt("%s /" TEST_ACCOUNT "/" TEST_CONTAINER, verb); @@ -45,20 +45,20 @@ testRequest(IoWrite *write, const char *verb, const char *uri, TestRequestParam if (driver->sasKey != NULL) { HttpQuery *query = httpQueryNewP(); - StringList *uriQuery = strLstNewSplitZ(STR(uri), "?"); + StringList *pathQuery = strLstNewSplitZ(STR(path), "?"); - if (strLstSize(uriQuery) == 2) - query = httpQueryNewStr(strLstGet(uriQuery, 1)); + if (strLstSize(pathQuery) == 2) + query = httpQueryNewStr(strLstGet(pathQuery, 1)); httpQueryMerge(query, driver->sasKey); - strCat(request, strLstGet(uriQuery, 0)); + strCat(request, strLstGet(pathQuery, 0)); strCatZ(request, "?"); strCat(request, httpQueryRenderP(query)); } - // Else just output URI as is + // Else just output path as is else - strCatZ(request, uri); + strCatZ(request, path); // Add HTTP version and user agent strCatZ(request, " HTTP/1.1\r\nuser-agent:" PROJECT_NAME "/" PROJECT_VERSION "\r\n"); @@ -192,7 +192,7 @@ testRun(void) TEST_RESULT_STR(((StorageAzure *)storage->driver)->container, TEST_CONTAINER_STR, " check container"); TEST_RESULT_STR(((StorageAzure *)storage->driver)->sharedKey, TEST_KEY_SHARED_STR, " check key"); TEST_RESULT_STR_Z(((StorageAzure *)storage->driver)->host, TEST_ACCOUNT ".blob.core.windows.net", " check host"); - TEST_RESULT_STR_Z(((StorageAzure *)storage->driver)->uriPrefix, "/" TEST_CONTAINER, " check uri prefix"); + TEST_RESULT_STR_Z(((StorageAzure *)storage->driver)->pathPrefix, "/" TEST_CONTAINER, " check path prefix"); TEST_RESULT_UINT(((StorageAzure *)storage->driver)->blockSize, STORAGE_AZURE_BLOCKSIZE_MIN, " check block size"); TEST_RESULT_BOOL(storageFeature(storage, storageFeaturePath), false, " check path feature"); TEST_RESULT_BOOL(storageFeature(storage, storageFeatureCompress), false, " check compress feature"); @@ -299,7 +299,7 @@ testRun(void) driver = (StorageAzure *)storage->driver; TEST_RESULT_STR(driver->host, hrnServerHost(), " check host"); - TEST_RESULT_STR_Z(driver->uriPrefix, "/" TEST_ACCOUNT "/" TEST_CONTAINER, " check uri prefix"); + TEST_RESULT_STR_Z(driver->pathPrefix, "/" TEST_ACCOUNT "/" TEST_CONTAINER, " check path prefix"); TEST_RESULT_BOOL(driver->fileId == 0, false, " check file id"); // Tests need the block size to be 16 @@ -357,7 +357,7 @@ testRun(void) TEST_ERROR_FMT( ioReadOpen(storageReadIo(read)), ProtocolError, "HTTP request failed with 303:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/account/container/file.txt\n" "*** Request Headers ***:\n" "authorization: \n" @@ -380,7 +380,7 @@ testRun(void) TEST_ERROR_FMT( storagePutP(storageNewWriteP(storage, strNew("file.txt")), BUFSTRDEF("ABCD")), ProtocolError, "HTTP request failed with 403 (Forbidden):\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/account/container/file.txt\n" "*** Request Headers ***:\n" "authorization: \n" @@ -759,7 +759,7 @@ testRun(void) TEST_ERROR_FMT( storagePathRemoveP(storage, strNew("/"), .recurse = true), ProtocolError, "HTTP request failed with 403 (Forbidden):\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/account/container?comp=list&restype=container&sig=\n" "*** Request Headers ***:\n" "content-length: 0\n" diff --git a/test/src/module/storage/s3Test.c b/test/src/module/storage/s3Test.c index c50c5eac5..af87967d4 100644 --- a/test/src/module/storage/s3Test.c +++ b/test/src/module/storage/s3Test.c @@ -28,11 +28,11 @@ typedef struct TestRequestParam const char *securityToken; } TestRequestParam; -#define testRequestP(write, s3, verb, uri, ...) \ - testRequest(write, s3, verb, uri, (TestRequestParam){VAR_PARAM_INIT, __VA_ARGS__}) +#define testRequestP(write, s3, verb, path, ...) \ + testRequest(write, s3, verb, path, (TestRequestParam){VAR_PARAM_INIT, __VA_ARGS__}) static void -testRequest(IoWrite *write, Storage *s3, const char *verb, const char *uri, TestRequestParam param) +testRequest(IoWrite *write, Storage *s3, const char *verb, const char *path, TestRequestParam param) { // Get security token from param const char *securityToken = param.securityToken == NULL ? NULL : param.securityToken; @@ -50,7 +50,7 @@ testRequest(IoWrite *write, Storage *s3, const char *verb, const char *uri, Test } // Add request - String *request = strNewFmt("%s %s HTTP/1.1\r\nuser-agent:" PROJECT_NAME "/" PROJECT_VERSION "\r\n", verb, uri); + String *request = strNewFmt("%s %s HTTP/1.1\r\nuser-agent:" PROJECT_NAME "/" PROJECT_VERSION "\r\n", verb, path); // Add authorization header when s3 service if (s3 != NULL) @@ -471,7 +471,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_URI); + testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_PATH); testResponseP(auth, .http = "1.0", .code = 301); hrnServerScriptClose(auth); @@ -479,7 +479,7 @@ testRun(void) TEST_ERROR_FMT( storageGetP(storageNewReadP(s3, strNew("file.txt"))), ProtocolError, "HTTP request failed with 301:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/latest/meta-data/iam/security-credentials\n" "*** Request Headers ***:\n" "content-length: 0\n" @@ -491,7 +491,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_URI); + testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_PATH); testResponseP(auth, .http = "1.0", .code = 404); hrnServerScriptClose(auth); @@ -506,13 +506,13 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_URI); + testRequestP(auth, NULL, HTTP_VERB_GET, S3_CREDENTIAL_PATH); testResponseP(auth, .http = "1.0", .content = strZ(credRole)); hrnServerScriptClose(auth); hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(credRole)))); + testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)))); testResponseP(auth, .http = "1.0", .code = 300); hrnServerScriptClose(auth); @@ -520,7 +520,7 @@ testRun(void) TEST_ERROR_FMT( storageGetP(storageNewReadP(s3, strNew("file.txt"))), ProtocolError, "HTTP request failed with 300:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/latest/meta-data/iam/security-credentials/credrole\n" "*** Request Headers ***:\n" "content-length: 0\n" @@ -532,7 +532,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(credRole)))); + testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)))); testResponseP(auth, .http = "1.0", .code = 404); hrnServerScriptClose(auth); @@ -548,7 +548,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(credRole)))); + testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)))); testResponseP(auth, .http = "1.0", .content = "{\"Code\":\"IAM role is not configured\"}"); hrnServerScriptClose(auth); @@ -562,7 +562,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(credRole)))); + testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)))); testResponseP( auth, .content = strZ( @@ -584,7 +584,7 @@ testRun(void) TEST_ERROR( ioReadOpen(storageReadIo(read)), ProtocolError, "HTTP request failed with 303:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/file.txt\n" "*** Request Headers ***:\n" "authorization: \n" @@ -608,7 +608,7 @@ testRun(void) hrnServerScriptAccept(auth); - testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_URI "/%s", strZ(credRole)))); + testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)))); testResponseP( auth, .content = strZ( @@ -782,7 +782,7 @@ testRun(void) TEST_ERROR(storageListP(s3, strNew("/")), ProtocolError, "HTTP request failed with 344:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/?delimiter=%2F&list-type=2\n" "*** Request Headers ***:\n" "authorization: \n" @@ -806,7 +806,7 @@ testRun(void) TEST_ERROR(storageListP(s3, strNew("/")), ProtocolError, "HTTP request failed with 344:\n" - "*** URI/Query ***:\n" + "*** Path/Query ***:\n" "/?delimiter=%2F&list-type=2\n" "*** Request Headers ***:\n" "authorization: \n"