-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add redirect::Policy::none to wasm builder
- Loading branch information
Showing
5 changed files
with
60 additions
and
4 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
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,41 @@ | ||
//! Redirect Handling | ||
//! | ||
//! By default, a `Client` will automatically follow HTTP redirects. To customize this behavior, a | ||
//! `redirect::Policy` can be used with a `ClientBuilder`. | ||
|
||
/// A type that controls the policy on how to handle the following of redirects. | ||
/// | ||
/// The default value follow redirects https://developer.mozilla.org/en-US/docs/Web/API/Request/redirect | ||
/// | ||
/// - `none` can be used to disable all redirect behavior. This sets the redirect value to "manual". | ||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct Policy { | ||
inner: PolicyKind, | ||
} | ||
|
||
impl Policy { | ||
/// Create a `Policy` that does not follow any redirect. | ||
pub fn none() -> Self { | ||
Self { | ||
inner: PolicyKind::None, | ||
} | ||
} | ||
|
||
fn not_set() -> Self { | ||
Self { | ||
inner: PolicyKind::NotSet, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
enum PolicyKind { | ||
None, | ||
NotSet, | ||
} | ||
|
||
impl Default for Policy { | ||
fn default() -> Policy { | ||
Policy::not_set() | ||
} | ||
} |