From a0f6828ccf6a42643eef91ef48f38f0dada52218 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Wed, 12 Oct 2022 07:49:31 -0700 Subject: [PATCH] Release 0.7.0 (#546) Ensure that we don't print internal warnings on user applications. Signed-off-by: David Calavera Signed-off-by: David Calavera --- lambda-extension/Cargo.toml | 4 ++-- lambda-http/Cargo.toml | 4 ++-- lambda-http/src/request.rs | 9 +++++++-- lambda-http/src/response.rs | 13 ++++++------- lambda-integration-tests/Cargo.toml | 6 +++--- lambda-runtime-api-client/Cargo.toml | 2 +- lambda-runtime/Cargo.toml | 4 ++-- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lambda-extension/Cargo.toml b/lambda-extension/Cargo.toml index 838d237f..823e3f82 100644 --- a/lambda-extension/Cargo.toml +++ b/lambda-extension/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambda-extension" -version = "0.6.0" +version = "0.7.0" edition = "2021" authors = [ "David Calavera ", @@ -19,7 +19,7 @@ bytes = "1.0" chrono = { version = "0.4", features = ["serde"] } http = "0.2" hyper = { version = "0.14.20", features = ["http1", "client", "server", "stream", "runtime"] } -lambda_runtime_api_client = { version = "0.6", path = "../lambda-runtime-api-client" } +lambda_runtime_api_client = { version = "0.7", path = "../lambda-runtime-api-client" } serde = { version = "1", features = ["derive"] } serde_json = "^1" tracing = { version = "0.1", features = ["log"] } diff --git a/lambda-http/Cargo.toml b/lambda-http/Cargo.toml index 541c4410..a553f871 100644 --- a/lambda-http/Cargo.toml +++ b/lambda-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambda_http" -version = "0.6.2" +version = "0.7.0" authors = [ "David Calavera ", "Harold Sun " @@ -28,7 +28,7 @@ bytes = "1" http = "0.2" http-body = "0.4" hyper = "0.14.20" -lambda_runtime = { path = "../lambda-runtime", version = "0.6" } +lambda_runtime = { path = "../lambda-runtime", version = "0.7" } serde = { version = "^1", features = ["derive"] } serde_json = "^1" serde_urlencoded = "0.7.0" diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index 9b3d63f7..e316a5a2 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -3,7 +3,9 @@ //! Typically these are exposed via the `request_context` //! request extension method provided by [lambda_http::RequestExt](../trait.RequestExt.html) //! -use crate::ext::{PathParameters, QueryStringParameters, RawHttpPath, StageVariables}; +#[cfg(any(feature = "apigw_rest", feature = "apigw_http", feature = "apigw_websockets"))] +use crate::ext::{PathParameters, StageVariables}; +use crate::ext::{QueryStringParameters, RawHttpPath}; #[cfg(feature = "alb")] use aws_lambda_events::alb::{AlbTargetGroupRequest, AlbTargetGroupRequestContext}; #[cfg(feature = "apigw_rest")] @@ -19,7 +21,6 @@ use serde::Deserialize; use serde_json::error::Error as JsonError; use std::future::Future; use std::pin::Pin; -use std::str::FromStr; use std::{io::Read, mem}; use url::Url; @@ -246,7 +247,10 @@ fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request { req } +#[cfg(feature = "alb")] fn decode_query_map(query_map: QueryMap) -> QueryMap { + use std::str::FromStr; + let query_string = query_map.to_query_string(); let decoded = percent_encoding::percent_decode(query_string.as_bytes()).decode_utf8_lossy(); QueryMap::from_str(&decoded).unwrap_or_default() @@ -304,6 +308,7 @@ fn into_websocket_request(ag: ApiGatewayWebsocketProxyRequest) -> http::Request< req } +#[cfg(any(feature = "apigw_rest", feature = "apigw_http", feature = "apigw_websockets"))] fn apigw_path_with_stage(stage: &Option, path: &str) -> String { match stage { None => path.into(), diff --git a/lambda-http/src/response.rs b/lambda-http/src/response.rs index 6db18f49..b174f98e 100644 --- a/lambda-http/src/response.rs +++ b/lambda-http/src/response.rs @@ -11,10 +11,7 @@ use aws_lambda_events::encodings::Body; use encoding_rs::Encoding; use http::header::CONTENT_ENCODING; use http::HeaderMap; -use http::{ - header::{CONTENT_TYPE, SET_COOKIE}, - Response, -}; +use http::{header::CONTENT_TYPE, Response}; use http_body::Body as HttpBody; use hyper::body::to_bytes; use mime::{Mime, CHARSET}; @@ -28,7 +25,7 @@ const X_LAMBDA_HTTP_CONTENT_ENCODING: &str = "x-lambda-http-content-encoding"; // See list of common MIME types: // - https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types // - https://github.com/ietf-wg-httpapi/mediatypes/blob/main/draft-ietf-httpapi-yaml-mediatypes.md -const TEXT_ENCODING_PREFIXES: [&'static str; 5] = [ +const TEXT_ENCODING_PREFIXES: [&str; 5] = [ "text", "application/json", "application/javascript", @@ -36,7 +33,7 @@ const TEXT_ENCODING_PREFIXES: [&'static str; 5] = [ "application/yaml", ]; -const TEXT_ENCODING_SUFFIXES: [&'static str; 3] = ["+xml", "+yaml", "+json"]; +const TEXT_ENCODING_SUFFIXES: [&str; 3] = ["+xml", "+yaml", "+json"]; /// Representation of Lambda response #[doc(hidden)] @@ -61,7 +58,7 @@ impl LambdaResponse { b @ Body::Binary(_) => (true, Some(b)), }; - let mut headers = parts.headers; + let headers = parts.headers; let status_code = parts.status.as_u16(); match request_origin { @@ -75,6 +72,8 @@ impl LambdaResponse { }), #[cfg(feature = "apigw_http")] RequestOrigin::ApiGatewayV2 => { + use http::header::SET_COOKIE; + let mut headers = headers; // ApiGatewayV2 expects the set-cookies headers to be in the "cookies" attribute, // so remove them from the headers. let cookies = headers diff --git a/lambda-integration-tests/Cargo.toml b/lambda-integration-tests/Cargo.toml index bb4a6aea..116b2986 100644 --- a/lambda-integration-tests/Cargo.toml +++ b/lambda-integration-tests/Cargo.toml @@ -13,9 +13,9 @@ readme = "../README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lambda_http = { path = "../lambda-http", version = "0.6" } -lambda_runtime = { path = "../lambda-runtime", version = "0.6" } -lambda-extension = { path = "../lambda-extension", version = "0.6" } +lambda_http = { path = "../lambda-http", version = "0.7" } +lambda_runtime = { path = "../lambda-runtime", version = "0.7" } +lambda-extension = { path = "../lambda-extension", version = "0.7" } serde = { version = "1", features = ["derive"] } tokio = { version = "1", features = ["full"] } tracing = { version = "0.1", features = ["log"] } diff --git a/lambda-runtime-api-client/Cargo.toml b/lambda-runtime-api-client/Cargo.toml index 03b1863a..dab52a48 100644 --- a/lambda-runtime-api-client/Cargo.toml +++ b/lambda-runtime-api-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambda_runtime_api_client" -version = "0.6.0" +version = "0.7.0" edition = "2021" authors = [ "David Calavera ", diff --git a/lambda-runtime/Cargo.toml b/lambda-runtime/Cargo.toml index ee33b736..14c675b6 100644 --- a/lambda-runtime/Cargo.toml +++ b/lambda-runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambda_runtime" -version = "0.6.1" +version = "0.7.0" authors = [ "David Calavera ", "Harold Sun " @@ -30,4 +30,4 @@ async-stream = "0.3" tracing = { version = "0.1", features = ["log"] } tower = { version = "0.4", features = ["util"] } tokio-stream = "0.1.2" -lambda_runtime_api_client = { version = "0.6", path = "../lambda-runtime-api-client" } +lambda_runtime_api_client = { version = "0.7", path = "../lambda-runtime-api-client" }