Commit 257ca4c0 authored by AWS SDK Rust Bot's avatar AWS SDK Rust Bot
Browse files

[smithy-rs] Rollup of 6 commits



Includes commits:
  c8edefee Fix dry run credentials check (#3137)
  59a47833 First pass at optimizing SplitOnWordBoundaries (#3140)
  8abeb04f Move http types out of client and split headers out of request (#3138)
  b694ee2a Update Canary OIDC provider, NPM commands, and previous version pagination test (#3142)
  cfdec948 Re-export generic default (#3144)
  315d88b6 Lifetimes of inner references (#3141)

Co-authored-by: default avatar82marbag <69267416+82marbag@users.noreply.github.com>
Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
Co-authored-by: default avatarZelda Hessler <zhessler@amazon.com>
parent e155df82
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ mod xml;
use crate::sealed::GetNormalizedHeader;
use crate::xml::try_xml_equivalent;
use assert_json_diff::assert_json_eq_no_panic;
use aws_smithy_runtime_api::client::http::request::Headers;
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::http::Headers;
use http::{HeaderMap, Uri};
use pretty_assertions::Comparison;
use std::collections::HashSet;
@@ -413,8 +413,8 @@ mod tests {
        forbid_headers, forbid_query_params, require_headers, require_query_params, validate_body,
        validate_headers, validate_query_string, FloatEquals, MediaType, ProtocolTestFailure,
    };
    use aws_smithy_runtime_api::client::http::request::Headers;
    use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
    use aws_smithy_runtime_api::http::Headers;

    fn make_request(uri: &str) -> HttpRequest {
        let mut req = HttpRequest::empty();
+36 −3
Original line number Diff line number Diff line
@@ -50,9 +50,6 @@
//! [`tower`]: https://crates.io/crates/tower
//! [`aws-smithy-runtime`]: https://crates.io/crates/aws-smithy-runtime

pub mod request;
pub mod response;

use crate::client::orchestrator::{HttpRequest, HttpResponse};
use crate::client::result::ConnectorError;
use crate::client::runtime_components::sealed::ValidateConfig;
@@ -62,6 +59,26 @@ use std::fmt;
use std::sync::Arc;
use std::time::Duration;

/// Http Request Types
pub mod request {
    use aws_smithy_types::body::SdkBody;
    /// Deprecated: This type has moved to `aws_smithy_runtime_api::http::HttpError`.
    #[deprecated(note = "This type has moved to `aws_smithy_runtime_api::http::HttpError`.")]
    pub type HttpError = crate::http::HttpError;
    /// Deprecated: This type has moved to `aws_smithy_runtime_api::http::HeaderValue`.
    #[deprecated(note = "This type has moved to `aws_smithy_runtime_api::http::HeaderValue`.")]
    pub type HeaderValue = crate::http::HeaderValue;
    /// Deprecated: This type has moved to `aws_smithy_runtime_api::http::Headers`.
    #[deprecated(note = "This type has moved to `aws_smithy_runtime_api::http::Headers`.")]
    pub type Headers = crate::http::Headers;
    /// Deprecated: This type has moved to `aws_smithy_runtime_api::http::HeadersIter`.
    #[deprecated(note = "This type has moved to `aws_smithy_runtime_api::http::HeadersIter`.")]
    pub type HeadersIter<'a> = crate::http::HeadersIter<'a>;
    /// Deprecated: This type has moved to `aws_smithy_runtime_api::http::Request`.
    #[deprecated(note = "This type has moved to `aws_smithy_runtime_api::http::Request`.")]
    pub type Request<B = SdkBody> = crate::http::Request<B>;
}

new_type_future! {
    #[doc = "Future for [`HttpConnector::call`]."]
    pub struct HttpConnectorFuture<'static, HttpResponse, ConnectorError>;
@@ -263,3 +280,19 @@ impl HttpConnectorSettings {
        self.read_timeout
    }
}

#[cfg(test)]
mod test {
    #[test]
    #[allow(deprecated)]
    fn re_export_has_default_generic() {
        let req1 = super::request::Request::empty();
        let req2 = super::request::Request::<()>::new(());
        fn takes_req(_req: &super::request::Request) {}
        fn takes_generic_req<B>(_req: &super::request::Request<B>) {}

        takes_req(&req1);
        takes_generic_req(&req1);
        takes_generic_req(&req2);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ use std::error::Error as StdError;
use std::fmt;

/// Type alias for the HTTP request type that the orchestrator uses.
pub type HttpRequest = crate::client::http::request::Request;
pub type HttpRequest = crate::http::Request;

/// Type alias for the HTTP response type that the orchestrator uses.
pub type HttpResponse = http::Response<SdkBody>;
+14 −0
Original line number Diff line number Diff line
@@ -3,4 +3,12 @@
 * SPDX-License-Identifier: Apache-2.0
 */

//! Http Response Types
//! HTTP request and response types

mod error;
mod headers;
mod request;

pub use error::HttpError;
pub use headers::{HeaderValue, Headers, HeadersIter};
pub use request::Request;
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

//! Error types for HTTP requests/responses.

use crate::box_error::BoxError;
use http::header::{InvalidHeaderName, InvalidHeaderValue};
use http::uri::InvalidUri;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::str::Utf8Error;

#[derive(Debug)]
/// An error occurred constructing an Http Request.
///
/// This is normally due to configuration issues, internal SDK bugs, or other user error.
pub struct HttpError(BoxError);

impl HttpError {
    // TODO(httpRefactor): Add better error internals
    pub(super) fn new<E: Into<Box<dyn Error + Send + Sync + 'static>>>(err: E) -> Self {
        HttpError(err.into())
    }

    pub(super) fn invalid_header_value(err: InvalidHeaderValue) -> Self {
        Self(err.into())
    }

    pub(super) fn header_was_not_a_string(err: Utf8Error) -> Self {
        Self(err.into())
    }

    pub(super) fn invalid_header_name(err: InvalidHeaderName) -> Self {
        Self(err.into())
    }

    pub(super) fn invalid_uri(err: InvalidUri) -> Self {
        Self(err.into())
    }
}

impl Display for HttpError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "an error occurred creating an HTTP Request")
    }
}

impl Error for HttpError {
    fn source(&self) -> Option<&(dyn Error + 'static)> {
        Some(self.0.as_ref())
    }
}
Loading