Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Oct 13, 2023
1 parent 8803723 commit 451867a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-inlineable/src/presigning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl PresigningConfigBuilder {
///
/// **This struct has conversion convenience functions:**
///
/// - [`PresignedRequest::to_http_02x_request<B>`][Self::to_http_03x_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)
/// - [`PresignedRequest::to_http_02x_request<B>`][Self::to_http_02x_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)
/// - [`PresignedRequest::into`](#impl-From<PresignedRequest>) returns an [`http::request::Builder`](https://docs.rs/http/0.2.6/http/request/struct.Builder.html)
#[non_exhaustive]
pub struct PresignedRequest(HttpRequest);
Expand Down Expand Up @@ -199,7 +199,7 @@ impl PresignedRequest {
}

/// Given a body, convert this `PresignedRequest` into an `http::Request`
pub fn to_http_03x_request<B>(self, body: B) -> Result<http::Request<B>, BoxError> {
pub fn to_http_02x_request<B>(self, body: B) -> Result<http::Request<B>, BoxError> {
Ok(self.0.into_http02x()?.map(|_req| body))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fun String.doubleQuote(): String =
*/
fun String.dq(): String = this.doubleQuote()

val completeWords: List<String> = listOf("ipv4", "ipv6", "sigv4", "mib", "gib", "kib", "ttl")
private val completeWords: List<String> = listOf("ipv4", "ipv6", "sigv4", "mib", "gib", "kib", "ttl")
private fun String.splitOnWordBoundaries(): List<String> {
val out = mutableListOf<String>()
// These are whole words but cased differently, e.g. `IPv4`, `MiB`, `GiB`, `TtL`
Expand Down
4 changes: 2 additions & 2 deletions design/src/rfcs/rfc0037_http_wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ All header insertion methods accept `impl AsHeaderComponent`. This allows us to
advantage of zero-cost usage of `'static str`. We will seal this trait to prevent external usage. We will have separate implementation for:
- `&'static str`
- `String`
- http03x::HeaderName
- http02x::HeaderName

#### Additional Functionality
Our wrapper type will add the following additional functionality:
Expand Down Expand Up @@ -100,7 +100,7 @@ This also enables supporting request extensions for different downstream provide
</details>

### Future Work
Currently, the only way to construct `Request` is from a compatible type (e.g. `http03x::Request`)
Currently, the only way to construct `Request` is from a compatible type (e.g. `http02x::Request`)

Changes checklist
-----------------
Expand Down
16 changes: 8 additions & 8 deletions rust-runtime/aws-smithy-runtime-api/src/client/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<B> TryFrom<http0::Request<B>> for Request<B> {
parts
.headers
.into_iter()
.map(|(k, v)| (k, HeaderValue::from_http03x(v).expect("validated above"))),
.map(|(k, v)| (k, HeaderValue::from_http02x(v).expect("validated above"))),
);
Ok(Self {
body,
Expand Down Expand Up @@ -427,8 +427,8 @@ mod sealed {
/// If the component can be represented as a Cow<'static, str>, return it
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError>;

/// If a component is already internally represented as a `http03x::HeaderName`, return it
fn repr_as_http03x_header_name(self) -> Result<http0::HeaderName, Self>
/// If a component is already internally represented as a `http02x::HeaderName`, return it
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
where
Self: Sized,
{
Expand Down Expand Up @@ -469,7 +469,7 @@ mod sealed {
Ok(self.to_string().into())
}

fn repr_as_http03x_header_name(self) -> Result<http0::HeaderName, Self>
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
where
Self: Sized,
{
Expand All @@ -491,7 +491,7 @@ mod header_value {
}

impl HeaderValue {
pub(crate) fn from_http03x(value: http0::HeaderValue) -> Result<Self, Utf8Error> {
pub(crate) fn from_http02x(value: http0::HeaderValue) -> Result<Self, Utf8Error> {
let _ = std::str::from_utf8(value.as_bytes())?;
Ok(Self { _private: value })
}
Expand Down Expand Up @@ -537,7 +537,7 @@ impl TryFrom<String> for HeaderValue {
type Error = HttpError;

fn try_from(value: String) -> Result<Self, Self::Error> {
Ok(HeaderValue::from_http03x(
Ok(HeaderValue::from_http02x(
http0::HeaderValue::try_from(value).map_err(HttpError::invalid_header_value)?,
)
.expect("input was a string"))
Expand Down Expand Up @@ -588,7 +588,7 @@ impl Error for HttpError {
}

fn header_name(name: impl AsHeaderComponent) -> Result<http0::HeaderName, HttpError> {
name.repr_as_http03x_header_name().or_else(|name| {
name.repr_as_http02x_header_name().or_else(|name| {
name.into_maybe_static().and_then(|cow| {
if cow.chars().any(|c| c.is_uppercase()) {
return Err(HttpError::new("Header names must be all lower case"));
Expand All @@ -610,7 +610,7 @@ fn header_value(value: MaybeStatic) -> Result<HeaderValue, HttpError> {
http0::HeaderValue::try_from(s).map_err(HttpError::invalid_header_value)?
}
};
HeaderValue::from_http03x(header).map_err(HttpError::new)
HeaderValue::from_http02x(header).map_err(HttpError::new)
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn headers_to_map_http(headers: &Headers) -> HashMap<String, Vec<String>> {
out
}

fn headers_to_map_03x(headers: &HeaderMap) -> HashMap<String, Vec<String>> {
fn headers_to_map_02x(headers: &HeaderMap) -> HashMap<String, Vec<String>> {
let mut out: HashMap<_, Vec<_>> = HashMap::new();
for (header_name, header_value) in headers.iter() {
let entry = out.entry(header_name.to_string()).or_default();
Expand All @@ -135,7 +135,7 @@ impl<'a, B> From<&'a http::Response<B>> for Response {
fn from(resp: &'a http::Response<B>) -> Self {
let status = resp.status().as_u16();
let version = format!("{:?}", resp.version());
let headers = headers_to_map_03x(resp.headers());
let headers = headers_to_map_02x(resp.headers());
Self {
status,
version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ cp -r aws-sdk-smoketest "${tmp_dir}/aws/sdk/build/aws-sdk"
find "${tmp_dir}"

pushd "${tmp_dir}/aws/sdk/integration-tests"
cargo check --tests
cargo check --tests --all-features
popd
3 changes: 3 additions & 0 deletions tools/ci-scripts/check-rust-runtimes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ C_YELLOW='\033[1;33m'
C_RESET='\033[0m'

set -eux

: "$RUST_NIGHTLY_VERSION"

cd smithy-rs

for runtime_path in \
Expand Down

0 comments on commit 451867a

Please sign in to comment.