-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: 82marbag <[email protected]> Co-authored-by: John DiSanti <[email protected]> Co-authored-by: Russell Cohen <[email protected]> Co-authored-by: Zelda Hessler <[email protected]>
- Loading branch information
1 parent
e155df8
commit 257ca4c
Showing
11 changed files
with
464 additions
and
394 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 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.