diff --git a/deps/aws-lambda-cpp-0.2.6.tar.gz b/deps/aws-lambda-cpp-0.2.6.tar.gz deleted file mode 100644 index fe1fbae..0000000 Binary files a/deps/aws-lambda-cpp-0.2.6.tar.gz and /dev/null differ diff --git a/deps/aws-lambda-cpp-0.2.8.tar.gz b/deps/aws-lambda-cpp-0.2.8.tar.gz new file mode 100644 index 0000000..1de32b7 Binary files /dev/null and b/deps/aws-lambda-cpp-0.2.8.tar.gz differ diff --git a/deps/curl-7.84.0.tar.gz b/deps/curl-7.84.0.tar.gz deleted file mode 100644 index 2c08406..0000000 Binary files a/deps/curl-7.84.0.tar.gz and /dev/null differ diff --git a/deps/curl-7_84_0.tar.gz b/deps/curl-7_84_0.tar.gz new file mode 100644 index 0000000..76dcae0 Binary files /dev/null and b/deps/curl-7_84_0.tar.gz differ diff --git a/deps/patches/aws-lambda-cpp-add-content-type.patch b/deps/patches/aws-lambda-cpp-add-content-type.patch deleted file mode 100644 index 2e045ff..0000000 --- a/deps/patches/aws-lambda-cpp-add-content-type.patch +++ /dev/null @@ -1,53 +0,0 @@ -diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h -index e14b804..cc1a789 100644 ---- a/include/aws/lambda-runtime/runtime.h -+++ b/include/aws/lambda-runtime/runtime.h -@@ -56,6 +56,11 @@ struct invocation_request { - */ - std::string function_arn; - -+ /** -+ * The Content-type of the current invocation. -+ */ -+ std::string content_type; -+ - /** - * Function execution deadline counted in milliseconds since the Unix epoch. - */ -diff --git a/include/aws/http/response.h b/include/aws/http/response.h -index 9b8cbda..be184c1 100644 ---- a/include/aws/http/response.h -+++ b/include/aws/http/response.h -@@ -36,6 +36,7 @@ public: - inline void set_response_code(aws::http::response_code c); - inline void set_content_type(char const* ct); - inline std::string const& get_body() const; -+ inline std::string const& get_content_type() const; - - private: - response_code m_response_code; -@@ -137,6 +138,12 @@ inline std::string const& response::get_body() const - { - return m_body; - } -+ -+inline std::string const& response::get_content_type() const -+{ -+ return m_content_type; -+} -+ - inline void response::add_header(std::string name, std::string const& value) - { - std::transform(name.begin(), name.end(), name.begin(), ::tolower); -diff --git a/src/runtime.cpp b/src/runtime.cpp -index 08d7014..1cbd6bb 100644 ---- a/src/runtime.cpp -+++ b/src/runtime.cpp -@@ -275,6 +275,7 @@ runtime::next_outcome runtime::get_next() - invocation_request req; - req.payload = resp.get_body(); - req.request_id = resp.get_header(REQUEST_ID_HEADER); -+ req.content_type = resp.get_content_type(); - - if (resp.has_header(TRACE_ID_HEADER)) { - req.xray_trace_id = resp.get_header(TRACE_ID_HEADER); diff --git a/deps/patches/aws-lambda-cpp-make-lto-optional.patch b/deps/patches/aws-lambda-cpp-make-lto-optional.patch deleted file mode 100644 index f371f52..0000000 --- a/deps/patches/aws-lambda-cpp-make-lto-optional.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index eb8327f..e6eeda5 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -4,10 +4,9 @@ project(aws-lambda-runtime - VERSION 0.2.6 - LANGUAGES CXX) - -+option(ENABLE_LTO "Enables link-time optimization, requires compiler support." ON) - option(ENABLE_TESTS "Enables building the test project, requires AWS C++ SDK." OFF) - --include(CheckIPOSupported) -- - add_library(${PROJECT_NAME} - "src/logging.cpp" - "src/runtime.cpp" -@@ -23,11 +22,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) - --check_ipo_supported(RESULT has_lto OUTPUT lto_check_output) --if(has_lto) -- set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) --else() -- message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}") -+if (ENABLE_LTO) -+ include(CheckIPOSupported) -+ check_ipo_supported(RESULT has_lto OUTPUT lto_check_output) -+ if(has_lto) -+ set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -+ else() -+ message(WARNING "Link-time optimization (LTO) is not supported: ${lto_check_output}") -+ endif() - endif() - - find_package(CURL REQUIRED) \ No newline at end of file diff --git a/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch b/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch deleted file mode 100644 index 8be3552..0000000 --- a/deps/patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 846392515b2b0215902aaf7368651af196835f10 Mon Sep 17 00:00:00 2001 -From: Bryan Moffatt -Date: Wed, 21 Oct 2020 12:42:37 -0700 -Subject: [PATCH] make the Runtime Interface Client's user agent overrideable (#106) - -* make the Runtime Interface Client's user agent overrideable - -* remove extra empty string - -* clang-format -i src/* ---- - include/aws/lambda-runtime/runtime.h | 2 ++ - src/runtime.cpp | 20 ++++++++------------ - 2 files changed, 10 insertions(+), 12 deletions(-) - -diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h -index 0dc292c..94e1e22 100644 ---- a/include/aws/lambda-runtime/runtime.h -+++ b/include/aws/lambda-runtime/runtime.h -@@ -137,6 +137,7 @@ public: - using next_outcome = aws::lambda_runtime::outcome; - using post_outcome = aws::lambda_runtime::outcome; - -+ runtime(std::string const& endpoint, std::string const& user_agent); - runtime(std::string const& endpoint); - ~runtime(); - -@@ -164,6 +165,7 @@ private: - invocation_response const& handler_response); - - private: -+ std::string const m_user_agent_header; - std::array const m_endpoints; - CURL* const m_curl_handle; - }; -diff --git a/src/runtime.cpp b/src/runtime.cpp -index e2ee7cd..f6131a4 100644 ---- a/src/runtime.cpp -+++ b/src/runtime.cpp -@@ -124,12 +124,6 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata) - return size * nmemb; - } - --static std::string const& get_user_agent_header() --{ -- static std::string user_agent = std::string("User-Agent: AWS_Lambda_Cpp/") + get_version(); -- return user_agent; --} -- - static size_t read_data(char* buffer, size_t size, size_t nitems, void* userdata) - { - auto const limit = size * nitems; -@@ -163,10 +157,12 @@ static int rt_curl_debug_callback(CURL* handle, curl_infotype type, char* data, - } - #endif - --runtime::runtime(std::string const& endpoint) -- : m_endpoints{{endpoint + "/2018-06-01/runtime/init/error", -- endpoint + "/2018-06-01/runtime/invocation/next", -- endpoint + "/2018-06-01/runtime/invocation/"}}, -+runtime::runtime(std::string const& endpoint) : runtime(endpoint, "AWS_Lambda_Cpp/" + std::string(get_version())) {} -+ -+runtime::runtime(std::string const& endpoint, std::string const& user_agent) -+ : m_user_agent_header("User-Agent: " + user_agent), m_endpoints{{endpoint + "/2018-06-01/runtime/init/error", -+ endpoint + "/2018-06-01/runtime/invocation/next", -+ endpoint + "/2018-06-01/runtime/invocation/"}}, - m_curl_handle(curl_easy_init()) - { - if (!m_curl_handle) { -@@ -234,7 +230,7 @@ runtime::next_outcome runtime::get_next() - curl_easy_setopt(m_curl_handle, CURLOPT_HEADERDATA, &resp); - - curl_slist* headers = nullptr; -- headers = curl_slist_append(headers, get_user_agent_header().c_str()); -+ headers = curl_slist_append(headers, m_user_agent_header.c_str()); - curl_easy_setopt(m_curl_handle, CURLOPT_HTTPHEADER, headers); - - logging::log_debug(LOG_TAG, "Making request to %s", m_endpoints[Endpoints::NEXT].c_str()); -@@ -343,7 +343,7 @@ runtime::post_outcome runtime::do_post( - headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + xray_response).c_str()); - headers = curl_slist_append(headers, "Expect:"); - headers = curl_slist_append(headers, "transfer-encoding:"); -- headers = curl_slist_append(headers, get_user_agent_header().c_str()); -+ headers = curl_slist_append(headers, m_user_agent_header.c_str()); - - logging::log_debug( - LOG_TAG, "calculating content length... %s", ("content-length: " + std::to_string(payload.length())).c_str()); --- -2.25.2 - diff --git a/deps/patches/aws-lambda-cpp-posting-init-errors.patch b/deps/patches/aws-lambda-cpp-posting-init-errors.patch deleted file mode 100644 index 8d202b5..0000000 --- a/deps/patches/aws-lambda-cpp-posting-init-errors.patch +++ /dev/null @@ -1,206 +0,0 @@ -diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h -index be77d93..9597272 100644 ---- a/include/aws/lambda-runtime/runtime.h -+++ b/include/aws/lambda-runtime/runtime.h -@@ -67,28 +67,58 @@ struct invocation_request { - inline std::chrono::milliseconds get_time_remaining() const; - }; - --class invocation_response { --private: -+class runtime_response { -+protected: - /** -- * The output of the function which is sent to the lambda caller. -+ * The response payload from the runtime. - */ - std::string m_payload; - - /** - * The MIME type of the payload. -- * This is always set to 'application/json' in unsuccessful invocations. - */ - std::string m_content_type; - - /** -- * Flag to distinguish if the contents are for successful or unsuccessful invocations. -+ * The serialized XRay response header. - */ -- bool m_success; -+ std::string m_xray_response; - - /** -- * The serialized XRay response header. -+ * Instantiate an empty response. - */ -- std::string m_xray_response; -+ runtime_response() = default; -+public: -+ /* Create a runtime response with the given payload, content type and xray response. This can be used for constructing an -+ * initialization error response. For invocation success and failure response, see invocation_response. -+ */ -+ runtime_response(std::string const& payload, std::string const& content_type, std::string const& xray_response) -+ : m_payload(payload), m_content_type(content_type), m_xray_response(xray_response) -+ { -+ } -+ -+ /** -+ * Get the payload string. The string is assumed to be UTF-8 encoded. -+ */ -+ std::string const& get_payload() const { return m_payload; } -+ -+ /** -+ * Get the MIME type of the payload. -+ */ -+ std::string const& get_content_type() const { return m_content_type; } -+ -+ /** -+ * Get the XRay response string. The string is assumed to be UTF-8 encoded. -+ */ -+ std::string const& get_xray_response() const { return m_xray_response; } -+}; -+ -+class invocation_response: public runtime_response { -+private: -+ /** -+ * Flag to distinguish if the contents are for successful or unsuccessful invocations. -+ */ -+ bool m_success; - - /** - * Instantiate an empty response. Used by the static functions 'success' and 'failure' to create a populated -@@ -102,12 +132,10 @@ public: - // To support clients that need to control the entire error response body (e.g. adding a stack trace), this - // constructor should be used instead. - // Note: adding an overload to invocation_response::failure is not feasible since the parameter types are the same. -- invocation_response(std::string const& payload, std::string const& content_type, bool success, std::string const& xray_response): -- m_payload(payload), -- m_content_type(content_type), -- m_success(success), -- m_xray_response(xray_response) -- {} -+ invocation_response(std::string const& payload, std::string const& content_type, bool success, std::string const& xray_response) -+ : runtime_response(payload, content_type, xray_response), m_success(success) -+ { -+ } - - /** - * Create a successful invocation response with the given payload and content-type. -@@ -120,25 +148,10 @@ public: - */ - static invocation_response failure(std::string const& error_message, std::string const& error_type, std::string const& xray_response); - -- /** -- * Get the MIME type of the payload. -- */ -- std::string const& get_content_type() const { return m_content_type; } -- -- /** -- * Get the payload string. The string is assumed to be UTF-8 encoded. -- */ -- std::string const& get_payload() const { return m_payload; } -- - /** - * Returns true if the payload and content-type are set. Returns false if the error message and error types are set. - */ - bool is_success() const { return m_success; } -- -- /** -- * Get the XRay response string. The string isassumed to be UTF-8 encoded. -- */ -- std::string const& get_xray_response() const { return m_xray_response; } - }; - - struct no_result { -@@ -167,13 +180,19 @@ public: - */ - post_outcome post_failure(std::string const& request_id, invocation_response const& handler_response); - -+ /** -+ * Tells lambda that the runtime has failed during initialization. -+ */ -+ post_outcome post_init_error(runtime_response const& init_error_response); -+ - private: - void set_curl_next_options(); - void set_curl_post_result_options(); - post_outcome do_post( - std::string const& url, -- std::string const& request_id, -- invocation_response const& handler_response); -+ std::string const& content_type, -+ std::string const& payload, -+ std::string const& xray_response); - - private: - std::array const m_endpoints; -diff --git a/src/runtime.cpp b/src/runtime.cpp -index d895c4b..659666e 100644 ---- a/src/runtime.cpp -+++ b/src/runtime.cpp -@@ -311,37 +311,44 @@ runtime::next_outcome runtime::get_next() - runtime::post_outcome runtime::post_success(std::string const& request_id, invocation_response const& handler_response) - { - std::string const url = m_endpoints[Endpoints::RESULT] + request_id + "/response"; -- return do_post(url, request_id, handler_response); -+ return do_post(url, handler_response.get_content_type(), handler_response.get_payload(), handler_response.get_xray_response()); - } - - runtime::post_outcome runtime::post_failure(std::string const& request_id, invocation_response const& handler_response) - { - std::string const url = m_endpoints[Endpoints::RESULT] + request_id + "/error"; -- return do_post(url, request_id, handler_response); -+ return do_post(url, handler_response.get_content_type(), handler_response.get_payload(), handler_response.get_xray_response()); -+} -+ -+runtime::post_outcome runtime::post_init_error(runtime_response const& init_error_response) -+{ -+ std::string const url = m_endpoints[Endpoints::INIT]; -+ return do_post(url, init_error_response.get_content_type(), init_error_response.get_payload(), init_error_response.get_xray_response()); - } - - runtime::post_outcome runtime::do_post( - std::string const& url, -- std::string const& request_id, -- invocation_response const& handler_response) -+ std::string const& content_type, -+ std::string const& payload, -+ std::string const& xray_response) - { - set_curl_post_result_options(); - curl_easy_setopt(m_curl_handle, CURLOPT_URL, url.c_str()); - logging::log_info(LOG_TAG, "Making request to %s", url.c_str()); - - curl_slist* headers = nullptr; -- if (handler_response.get_content_type().empty()) { -+ if (content_type.empty()) { - headers = curl_slist_append(headers, "content-type: text/html"); - } - else { -- headers = curl_slist_append(headers, ("content-type: " + handler_response.get_content_type()).c_str()); -+ headers = curl_slist_append(headers, ("content-type: " + content_type).c_str()); - } - -- headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + handler_response.get_xray_response()).c_str()); -+ headers = curl_slist_append(headers, ("lambda-runtime-function-xray-error-cause: " + xray_response).c_str()); - headers = curl_slist_append(headers, "Expect:"); - headers = curl_slist_append(headers, "transfer-encoding:"); - headers = curl_slist_append(headers, get_user_agent_header().c_str()); -- auto const& payload = handler_response.get_payload(); -+ - logging::log_debug( - LOG_TAG, "calculating content length... %s", ("content-length: " + std::to_string(payload.length())).c_str()); - headers = curl_slist_append(headers, ("content-length: " + std::to_string(payload.length())).c_str()); -@@ -358,10 +365,10 @@ runtime::post_outcome runtime::do_post( - if (curl_code != CURLE_OK) { - logging::log_debug( - LOG_TAG, -- "CURL returned error code %d - %s, for invocation %s", -+ "CURL returned error code %d - %s, when calling %s", - curl_code, - curl_easy_strerror(curl_code), -- request_id.c_str()); -+ url.c_str()); - return aws::http::response_code::REQUEST_NOT_MADE; - } - diff --git a/deps/versions b/deps/versions index bdff5db..7cac6b4 100644 --- a/deps/versions +++ b/deps/versions @@ -1,2 +1,2 @@ -AWS_LAMBDA_CPP_RELEASE=0.2.6 -CURL_VERSION=7.84.0 \ No newline at end of file +AWS_LAMBDA_CPP_RELEASE=0.2.8 +CURL_VERSION=7_84_0 diff --git a/scripts/preinstall.sh b/scripts/preinstall.sh index d65dfc4..087755c 100755 --- a/scripts/preinstall.sh +++ b/scripts/preinstall.sh @@ -25,7 +25,7 @@ else ( # Build Curl - cd curl-$CURL_VERSION && \ + cd curl-curl-$CURL_VERSION && \ ./buildconf && \ ./configure \ --prefix "$ARTIFACTS_DIR" \ diff --git a/scripts/update_dependencies.sh b/scripts/update_dependencies.sh index 3c087af..2210bad 100755 --- a/scripts/update_dependencies.sh +++ b/scripts/update_dependencies.sh @@ -10,19 +10,15 @@ source versions rm -f aws-lambda-cpp-*.tar.gz && rm -f curl-*.tar.gz # Grab Curl -wget -c https://github.com/curl/curl/archive/curl-$CURL_VERSION.tar.gz +wget -c https://github.com/curl/curl/archive/refs/tags/curl-$CURL_VERSION.tar.gz # Grab aws-lambda-cpp -wget -c https://github.com/awslabs/aws-lambda-cpp/archive/v$AWS_LAMBDA_CPP_RELEASE.tar.gz -O - | tar -xz +wget -c https://github.com/awslabs/aws-lambda-cpp/archive/refs/tags/v$AWS_LAMBDA_CPP_RELEASE.tar.gz -O - | tar -xz # Apply patches ( cd aws-lambda-cpp-$AWS_LAMBDA_CPP_RELEASE && \ - patch -p1 < ../patches/aws-lambda-cpp-add-xray-response.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-posting-init-errors.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-make-the-runtime-client-user-agent-overrideable.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-make-lto-optional.patch && \ - patch -p1 < ../patches/aws-lambda-cpp-add-content-type.patch + patch -p1 < ../patches/aws-lambda-cpp-add-xray-response.patch ) # Pack again and remove the folder