pub(crate) async fn preprocess_request(
        &self,
        req: &mut Request<'_>,
        data: &mut Data
    ) -> RequestToken {
        // Check if this is a form and if the form contains the special _method
        // field which we use to reinterpret the request's method.
        let (min_len, max_len) = ("_method=get".len(), "_method=delete".len());
        let peek_buffer = data.peek(max_len).await;
        let is_form = req.content_type().map_or(false, |ct| ct.is_form());

        if is_form && req.method() == Method::Post && peek_buffer.len() >= min_len {
            let method = std::str::from_utf8(peek_buffer).ok()
                .and_then(|raw_form| Form::values(raw_form).next())
                .filter(|field| field.name == "_method")
                .and_then(|field| field.value.parse().ok());

            if let Some(method) = method {
                req._set_method(method);
            }
        }

        // Run request fairings.
        self.fairings.handle_request(req, data).await;

        RequestToken
    }
/// Preprocess the request for Rocket things. Currently, this means:
///
///   * Rewriting the method in the request if _method form field exists.
///   * Run the request fairings.
///
/// Keep this in-sync with derive_form when preprocessing form fields.
Preprocess the request for Rocket things. Currently, this means:
Rewriting the method in the request if _method form field exists.
Run the request fairings.

Keep this in-sync with derive_form when preprocessing form fields.
Preprocess the request for Rocket things . Currently this means : Rewriting the method in the request if _method form field exists . Run the request fairings . Keep this in - sync with derive_form when preprocessing form fields .
pub(crate) async fn preprocess_request(
        &self,
        req: &mut Request<'_>,
        data: &mut Data
    ) -> RequestToken {
        // Check if this is a form and if the form contains the special _method
        // field which we use to reinterpret the request's method.
        let (min_len, max_len) = ("_method=get".len(), "_method=delete".len());
        let peek_buffer = data.peek(max_len).await;
        let is_form = req.content_type().map_or(false, |ct| ct.is_form());
        if is_form && req.method() == Method::Post && peek_buffer.len() >= min_len {
            let method = std::str::from_utf8(peek_buffer).ok()
                .and_then(|raw_form| Form::values(raw_form).next())
                .filter(|field| field.name == "_method")
                .and_then(|field| field.value.parse().ok());
            if let Some(method) = method {
                req._set_method(method);
            }
        }
        // Run request fairings.
        self.fairings.handle_request(req, data).await;
        RequestToken
    }
pub ( crate ) async fn preprocess_request ( & self , req : & mut Request < ' _ > , data : & mut Data ) -> RequestToken { // Check if this is a form and if the form contains the special _method // field which we use to reinterpret the request's method. let ( min_len , max_len ) = ( " " . len ( ) , " " . len ( ) ) ; let peek_buffer = data . peek ( max_len ) . await ; let is_form = req . content_type ( ) . map_or ( false , | ct | ct . is_form ( ) ) ; if is_form && req . method ( ) == Method :: Post && peek_buffer . len ( ) >= min_len { let method = std :: str :: from_utf8 ( peek_buffer ) . ok ( ) . and_then ( | raw_form | Form :: values ( raw_form ) . next ( ) ) . filter ( | field | field . name == " " ) . and_then ( | field | field . value . parse ( ) . ok ( ) ) ; if let Some ( method ) = method { req . _set_method ( method ) ; } } // Run request fairings. self . fairings . handle_request ( req , data ) . await ; RequestToken }
Preprocess the request for Rocket things.
Preprocess the request for Rocket things .
&self
req
&mut Request<'_>
data
&mut Data
&self
req
&mut Request<'_>
data
&mut Data