/// Returns if the received request is definitely bad.
///
/// Just because a request parses doesn't mean it's correct. For examples:
///
/// - `GET example.com`
/// - `CONNECT /just-a-path
Returns if the received request is definitely bad.
Just because a request parses doesn't mean it's correct. For examples.


Returns if the received request is definitely bad . Just because a request parses doesn ' t mean it ' s correct . For examples .
pub(crate) fn is_bad_request<B>(req: &http::Request<B>) -> bool {
    if req.method() == http::Method::CONNECT {
        // CONNECT is only valid over HTTP/1.1
        if req.version() != http::Version::HTTP_11 {
            debug!("CONNECT request not valid for HTTP/1.0: {:?}", req.uri());
            return true;
        }
        // CONNECT requests are only valid in authority-form.
        if !is_origin_form(req.uri()) {
            debug!("CONNECT request with illegal URI: {:?}", req.uri());
            return true;
        }
    } else if is_origin_form(req.uri()) {
        // If not CONNECT, refuse any origin-form URIs
        debug!("{} request with illegal URI: {:?}", req.method(), req.uri());
        return true;
    }
    false
}
pub ( crate ) fn is_bad_request < B > ( req : & http :: Request < B > ) -> bool { if req . method ( ) == http :: Method :: CONNECT { // CONNECT is only valid over HTTP/1.1 if req . version ( ) != http :: Version :: HTTP_11 { debug ! ( " " req uri ( ) ) ; return true ; } // CONNECT requests are only valid in authority-form. if ! is_origin_form ( req . uri ( ) ) { debug ! ( " " req uri ( ) ) ; return true ; } } else if is_origin_form ( req . uri ( ) ) { // If not CONNECT, refuse any origin-form URIs debug ! ( " " req method ( ) req uri ( ) ) ; return true ; } false }
Returns if the received request is definitely bad.
Returns if the received request is definitely bad .
req
&http::Request<B>