diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 082659acb..32d6dd3e4 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -55,6 +55,9 @@ + + +

Asynchronous S3 multipart upload.

diff --git a/src/common/io/http/request.c b/src/common/io/http/request.c index fa9911ab9..274f8aa14 100644 --- a/src/common/io/http/request.c +++ b/src/common/io/http/request.c @@ -219,7 +219,7 @@ httpRequestNew(HttpClient *client, const String *verb, const String *uri, HttpRe /**********************************************************************************************************************************/ HttpResponse * -httpRequest(HttpRequest *this, bool contentCache) +httpRequestResponse(HttpRequest *this, bool contentCache) { FUNCTION_LOG_BEGIN(logLevelDebug) FUNCTION_LOG_PARAM(HTTP_REQUEST, this); diff --git a/src/common/io/http/request.h b/src/common/io/http/request.h index 45aeed98c..f42275dbf 100644 --- a/src/common/io/http/request.h +++ b/src/common/io/http/request.h @@ -2,7 +2,7 @@ HTTP Request Send a request to an HTTP server and get a response. The interface is natively asynchronous, i.e. httpRequestNew() sends a request -and httpRequest() waits for a response. These can be called together for synchronous behavior or separately for asynchronous +and httpRequestResponse() waits for a response. These can be called together for synchronous behavior or separately for asynchronous behavior. ***********************************************************************************************************************************/ #ifndef COMMON_IO_HTTP_REQUEST_H @@ -71,8 +71,8 @@ HttpRequest *httpRequestNew(HttpClient *client, const String *verb, const String /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ -// Send a request to the server -HttpResponse *httpRequest(HttpRequest *this, bool contentCache); +// Wait for a response from the request +HttpResponse *httpRequestResponse(HttpRequest *this, bool contentCache); // Throw an error if the request failed void httpRequestError(const HttpRequest *this, HttpResponse *response) __attribute__((__noreturn__)); diff --git a/src/storage/azure/storage.c b/src/storage/azure/storage.c index a373f9408..0d4145e18 100644 --- a/src/storage/azure/storage.c +++ b/src/storage/azure/storage.c @@ -276,7 +276,7 @@ storageAzureResponse(HttpRequest *request, StorageAzureResponseParam param) MEM_CONTEXT_TEMP_BEGIN() { // Get response - result = httpRequest(request, !param.contentIo); + result = httpRequestResponse(request, !param.contentIo); // Error if the request was not successful if (!httpResponseCodeOk(result) && (!param.allowMissing || httpResponseCode(result) != HTTP_RESPONSE_CODE_NOT_FOUND)) diff --git a/src/storage/s3/storage.c b/src/storage/s3/storage.c index fcebce74a..facb2a1f3 100644 --- a/src/storage/s3/storage.c +++ b/src/storage/s3/storage.c @@ -302,7 +302,7 @@ storageS3Response(HttpRequest *request, StorageS3ResponseParam param) MEM_CONTEXT_TEMP_BEGIN() { // Get response - result = httpRequest(request, !param.contentIo); + result = httpRequestResponse(request, !param.contentIo); // Error if the request was not successful if (!httpResponseCodeOk(result) && (!param.allowMissing || httpResponseCode(result) != HTTP_RESPONSE_CODE_NOT_FOUND)) diff --git a/test/src/module/common/ioHttpTest.c b/test/src/module/common/ioHttpTest.c index fe1332725..9ca050b26 100644 --- a/test/src/module/common/ioHttpTest.c +++ b/test/src/module/common/ioHttpTest.c @@ -180,7 +180,7 @@ testRun(void) "new client"); TEST_ERROR_FMT( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), HostConnectError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), HostConnectError, "unable to connect to 'localhost:%u': [111] Connection refused", hrnTlsServerPort()); HARNESS_FORK_BEGIN() @@ -220,7 +220,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FileReadError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FileReadError, "unexpected eof while reading line"); // ----------------------------------------------------------------------------------------------------------------- @@ -234,7 +234,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "HTTP response status 'HTTP/1.0 200 OK' should be CR-terminated"); // ----------------------------------------------------------------------------------------------------------------- @@ -248,7 +248,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "HTTP response 'HTTP/1.0 200' has invalid length"); // ----------------------------------------------------------------------------------------------------------------- @@ -262,7 +262,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "HTTP version of response 'HTTP/1.0 200 OK' must be HTTP/1.1"); // ----------------------------------------------------------------------------------------------------------------- @@ -276,7 +276,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "response status '200OK' must have a space after the status code"); // ----------------------------------------------------------------------------------------------------------------- @@ -290,7 +290,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FileReadError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FileReadError, "unexpected eof while reading line"); // ----------------------------------------------------------------------------------------------------------------- @@ -304,7 +304,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "header 'header-value' missing colon"); // ----------------------------------------------------------------------------------------------------------------- @@ -318,7 +318,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "only 'chunked' is supported for 'transfer-encoding' header"); // ----------------------------------------------------------------------------------------------------------------- @@ -332,7 +332,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), FormatError, "'transfer-encoding' and 'content-length' headers are both set"); // ----------------------------------------------------------------------------------------------------------------- @@ -346,7 +346,7 @@ testRun(void) hrnTlsServerClose(); TEST_ERROR( - httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), ServiceError, + httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), ServiceError, "[503] Slow Down"); // ----------------------------------------------------------------------------------------------------------------- @@ -380,7 +380,7 @@ testRun(void) TEST_ASSIGN( request, httpRequestNewP(client, strNew("GET"), strNew("/"), .query = query, .header = headerRequest), "request"); - TEST_ASSIGN(response, httpRequest(request, false), "request"); + TEST_ASSIGN(response, httpRequestResponse(request, false), "request"); TEST_RESULT_VOID(httpRequestMove(request, memContextPrior()), "move request"); TEST_RESULT_VOID(httpResponseMove(response, memContextPrior()), "move response"); @@ -411,7 +411,7 @@ testRun(void) hrnTlsServerExpectZ("HEAD / HTTP/1.1\r\n\r\n"); hrnTlsServerReplyZ("HTTP/1.1 200 OK\r\ncontent-length:380\r\n\r\n"); - TEST_ASSIGN(response, httpRequest(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); + TEST_ASSIGN(response, httpRequestResponse(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); TEST_RESULT_UINT(httpResponseCode(response), 200, "check response code"); TEST_RESULT_STR_Z(httpResponseReason(response), "OK", "check response message"); TEST_RESULT_BOOL(httpResponseEof(response), true, "io is eof"); @@ -425,7 +425,7 @@ testRun(void) hrnTlsServerExpectZ("HEAD / HTTP/1.1\r\n\r\n"); hrnTlsServerReplyZ("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n"); - TEST_ASSIGN(response, httpRequest(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); + TEST_ASSIGN(response, httpRequestResponse(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); TEST_RESULT_UINT(httpResponseCode(response), 200, "check response code"); TEST_RESULT_STR_Z(httpResponseReason(response), "OK", "check response message"); TEST_RESULT_BOOL(httpResponseEof(response), true, "io is eof"); @@ -441,7 +441,7 @@ testRun(void) hrnTlsServerClose(); - TEST_ASSIGN(response, httpRequest(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); + TEST_ASSIGN(response, httpRequestResponse(httpRequestNewP(client, strNew("HEAD"), strNew("/")), true), "request"); TEST_RESULT_UINT(httpResponseCode(response), 200, "check response code"); TEST_RESULT_STR_Z(httpResponseReason(response), "OK", "check response message"); TEST_RESULT_BOOL(httpResponseEof(response), true, "io is eof"); @@ -470,7 +470,7 @@ testRun(void) hrnTlsServerReplyZ("HTTP/1.1 404 Not Found\r\n\r\n"); TEST_ASSIGN(request, httpRequestNewP(client, strNew("GET"), strNew("/")), "request"); - TEST_ASSIGN(response, httpRequest(request, false), "response"); + TEST_ASSIGN(response, httpRequestResponse(request, false), "response"); TEST_RESULT_UINT(httpResponseCode(response), 404, "check response code"); TEST_RESULT_BOOL(httpResponseCodeOk(response), false, "check response code error"); TEST_RESULT_STR_Z(httpResponseReason(response), "Not Found", "check response message"); @@ -501,7 +501,7 @@ testRun(void) client, strNew("GET"), strNew("/"), .query = httpQueryAdd(httpQueryNewP(), STRDEF("a"), STRDEF("b")), .header = headerRequest), "request"); - TEST_ASSIGN(response, httpRequest(request, false), "response"); + TEST_ASSIGN(response, httpRequestResponse(request, false), "response"); TEST_RESULT_UINT(httpResponseCode(response), 403, "check response code"); TEST_RESULT_STR_Z(httpResponseReason(response), "", "check empty response message"); TEST_RESULT_STR_Z( @@ -533,7 +533,7 @@ testRun(void) TEST_ASSIGN( response, - httpRequest( + httpRequestResponse( httpRequestNewP( client, strNew("GET"), strNew("/path/file 1.txt"), .header = httpHeaderAdd(httpHeaderNew(NULL), strNew("content-length"), strNew("30")), @@ -559,7 +559,7 @@ testRun(void) hrnTlsServerReplyZ("HTTP/1.1 200 OK\r\ncontent-length:32\r\n\r\n01234567890123456789012345678901"); TEST_ASSIGN( - response, httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/path/file 1.txt")), true), + response, httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/path/file 1.txt")), true), "request"); TEST_RESULT_STR_Z(strNewBuf(httpResponseContent(response)), "01234567890123456789012345678901", "check response"); TEST_RESULT_UINT(httpResponseRead(response, bufNew(1), true), 0, "call internal read to check eof"); @@ -573,7 +573,7 @@ testRun(void) hrnTlsServerClose(); TEST_ASSIGN( - response, httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/path/file 1.txt")), false), + response, httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/path/file 1.txt")), false), "request"); TEST_RESULT_PTR_NE(response->session, NULL, "session is busy"); TEST_ERROR(ioRead(httpResponseIoRead(response), bufNew(32)), FileReadError, "unexpected EOF reading HTTP content"); @@ -591,7 +591,7 @@ testRun(void) "10\r\n0123456789012345\r\n" "0\r\n\r\n"); - TEST_ASSIGN(response, httpRequest(httpRequestNewP(client, strNew("GET"), strNew("/")), false), "request"); + TEST_ASSIGN(response, httpRequestResponse(httpRequestNewP(client, strNew("GET"), strNew("/")), false), "request"); TEST_RESULT_STR_Z( httpHeaderToLog(httpResponseHeader(response)), "{transfer-encoding: 'chunked'}", "check response headers");