-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move http types out of client and split headers out of request (#3138)
This PR moves the HTTP types into the root of aws-smithy-runtime-api since they're not client-specific, and the serializers/deserializers will need to rely on them. It also refactors the headers and errors out of the request module. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
Showing
11 changed files
with
449 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
rust-runtime/aws-smithy-runtime-api/src/client/http/response.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//! 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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()) | ||
} | ||
} |
Oops, something went wrong.