1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use web_sys::RequestRedirect;

/// Request's redirect mode
#[derive(Debug, Clone, Copy, Default)]
pub enum Redirect {
    /// Follow all redirects incurred when fetching a resource.
    #[default]
    Follow,
    /// Return a network error when a request is met with a redirect.
    Error,
    /// Retrieves an opaque-redirect filtered response when a request is met with a redirect, to allow a service worker
    /// to replay the redirect offline. The response is otherwise indistinguishable from a network error, to not violate
    /// atomic HTTP redirect handling.
    Manual,
}

impl From<Redirect> for RequestRedirect {
    fn from(value: Redirect) -> Self {
        match value {
            Redirect::Follow => RequestRedirect::Follow,
            Redirect::Error => RequestRedirect::Error,
            Redirect::Manual => RequestRedirect::Manual,
        }
    }
}