Returns {@code true} if the request is a valid CORS pre-flight one.

@param request the http request
@return {@code true} if the request is a valid CORS pre-flight one, else {@code false}
357795
protected boolean isPreFlightRequest(HttpServletRequest request) {
        return (isCorsRequest(request)
                && MethodType.OPTIONS.name().equals(request.getMethod())
                && request.getHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD) != null);
    }
915801
public static boolean isAjaxRequest(HttpServletRequest request) {
        String ajaxHeader = request.getHeader("X-Requested-With");
        return StringUtils.isNotBlank(ajaxHeader) && "XMLHttpRequest".equalsIgnoreCase(ajaxHeader);
    }
549651
private boolean validateAssertion(final HttpServletRequest request, final String serviceTicketId, final Assertion assertion, final Service service) {
        for (val spec : serviceValidateConfigurationContext.getValidationSpecifications()) {
            spec.reset();
            val binder = new ServletRequestDataBinder(spec, "validationSpecification");
            initBinder(request, binder);
            binder.bind(request);
            if (!spec.isSatisfiedBy(assertion, request)) {
                LOGGER.warn("Service ticket [{}] does not satisfy validation specification.", serviceTicketId);
                return false;
            }
        }
        enforceTicketValidationAuthorizationFor(request, service, assertion);
        return true;
    }
1183108
public static boolean isGooglebot(HttpServletRequest request) {
		@SuppressWarnings("unchecked")
		Enumeration<String> headers = request.getHeaders("User-Agent");
		while(headers.hasMoreElements()) {
			String userAgent = headers.nextElement();
			if(userAgent.contains("Googlebot")) {
				// Verify through reverse then forward DNS lookups
				String remoteAddr = request.getRemoteAddr();
				String remoteHost = request.getRemoteHost();
				try {
					InetAddress remoteIp = InetAddress.getByName(remoteAddr);
					// Do reverse lookup if container didn't do so
					if(remoteAddr.equals(remoteHost)) remoteHost = remoteIp.getCanonicalHostName();
					// Reverse DNS result must be in the googlebot.com domain
					if(remoteHost.endsWith(".googlebot.com") || remoteHost.endsWith(".googlebot.com.")) {
						// Forward DNS must resolve back to the original IP
						for(InetAddress actualIp : InetAddress.getAllByName(remoteHost)) {
							System.out.println("DEBUG: ServletUtil: Googlebot verified: userAgent=\""+userAgent+"\", remoteAddr=\""+remoteAddr+"\", remoteHost=\""+remoteHost+"\"");
							if(actualIp.equals(remoteIp)) return true;
						}
						System.out.println("DEBUG: ServletUtil: Googlebot agent with valid reverse DNS failed forward lookup: userAgent=\""+userAgent+"\", remoteAddr=\""+remoteAddr+"\", remoteHost=\""+remoteHost+"\"");
					}
					System.out.println("DEBUG: ServletUtil: Googlebot agent failed valid reverse DNS lookup: userAgent=\""+userAgent+"\", remoteAddr=\""+remoteAddr+"\", remoteHost=\""+remoteHost+"\"");
				} catch(UnknownHostException exception) {
					// Ignored
					System.out.println("DEBUG: ServletUtil: Googlebot agent verification failed due to exception: userAgent=\""+userAgent+"\", remoteAddr=\""+remoteAddr+"\", remoteHost=\""+remoteHost+"\", exception=\""+exception+"\"");
				}
				break; // Only check the first Googlebot User-Agent header (there should normally only be one anyway)
			}
		}
		return false;
	}
1355851
protected boolean isAuthorizationRequest(final HttpServletRequest request, final HttpServletResponse response) {
        val requestPath = request.getRequestURI();
        return doesUriMatchPattern(requestPath, OAuth20Constants.AUTHORIZE_URL);
    }
588168
public void checkNoXSLT(final HttpServletRequest request) {
    String reqpar = request.getParameter(getNoXSLTRequestName());

    if (reqpar != null) {
      if (reqpar.equals("!")) {
        // Go back to unsticky noXslt
        setNoXSLTSticky(false);
      } else {
        setNoXSLT(true);
      }
    }

    reqpar = request.getParameter(getNoXSLTStickyRequestName());
    if (reqpar != null) {
      if (reqpar.equals("!")) {
        // Go back to unsticky noXslt
        setNoXSLTSticky(false);
      } else {
        setNoXSLT(true);
        setNoXSLTSticky(true);
      }
    }
  }
1149645
public boolean validate(HttpRequestMessage request, boolean isPostMethodAllowed) {
        WebSocketWireProtocol wireProtocolVersion = guessWireProtocolVersion(request);
        if ( wireProtocolVersion == null ) {
            return false;
        }

        final WsHandshakeValidator validator = handshakeValidatorsByWireProtocolVersion.get(wireProtocolVersion);
        return validator != null && validator.doValidate(request, isPostMethodAllowed);

    }
848045
public static boolean isSaneRequest(HttpServletRequest request) {
        if (request != null && request.getMethod() != null) {
            return true;
        }
        return false;
    }
635999
protected boolean isLoggingIn(final Request request, final Response response)
    {
        return this.isInterceptingLogin()
                && this.getLoginPath().equals(request.getResourceRef().getRemainingPart(false, false))
                && Method.POST.equals(request.getMethod());
    }
510441
public boolean preflightRequest() {
        try {
            final URL url = buildUrl(Checksum.getSHA1Checksum(UUID.randomUUID().toString()));
            final HttpURLConnection connection = connect(url);
            if (connection.getResponseCode() != 200) {
                LOGGER.warn("Expected 200 result from Artifactory ({}), got {}", url, connection.getResponseCode());
                return false;
            }
            return true;
        } catch (IOException e) {
            LOGGER.error("Cannot connect to Artifactory", e);
            return false;
        }

    }
1054687
def is_cors_enabled_on_request(self, request: web.Request) -> bool:
        """"""

        return self._request_resource(request) in self._resource_config
741939
def cors_options(self, request, **_):
        
        return create_response(
            request,
            headers=self.pre_flight_headers(request, request.supported_methods)
        )
1306922
public CORSRequestType checkRequestType(final HttpServletRequest request) {
		CORSRequestType requestType = CORSRequestType.INVALID_CORS;
		if (request == null) {
			throw new IllegalArgumentException(
					"HttpServletRequest object is null");
		}
		String originHeader = request.getHeader(REQUEST_HEADER_ORIGIN);
		// Section 6.1.1 and Section 6.2.1
		if (originHeader != null) {
			if (originHeader.isEmpty()) {
				requestType = CORSRequestType.INVALID_CORS;
			} else if (!isValidOrigin(originHeader)) {
				requestType = CORSRequestType.INVALID_CORS;
			} else {
				String method = StringUtils.trimToEmpty(request.getMethod());
				if (HTTP_METHODS.contains(method)) {
					if ("OPTIONS".equals(method)) {
						String accessControlRequestMethodHeader
								= request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
						if (StringUtils.isNotBlank(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.PRE_FLIGHT;
						} else if (StringUtils.isWhitespace(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.INVALID_CORS;
						} else {
							requestType = CORSRequestType.ACTUAL;
						}
					} else if ("GET".equals(method) || "HEAD".equals(method)) {
						requestType = CORSRequestType.SIMPLE;
					} else if ("POST".equals(method)) {
						String contentType = request.getContentType();
						if (contentType != null) {
							contentType = contentType.toLowerCase().trim();
							if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES
									.contains(contentType)) {
								requestType = CORSRequestType.SIMPLE;
							} else {
								requestType = CORSRequestType.ACTUAL;
							}
						}
					} else if (COMPLEX_HTTP_METHODS.contains(method)) {
						requestType = CORSRequestType.ACTUAL;
					}
				}
			}
		} else {
			requestType = CORSRequestType.NOT_CORS;
		}

		return requestType;
	}
851005
static boolean isLoginUIRequest(VaadinRequest request) {

        String referrer = request.getHeader("referer");
        return (referrer != null) && referrer.contains(CmsWorkplaceLoginHandler.LOGIN_HANDLER);
    }
1027206
public static boolean containsRoutingContext(RESTRequest request) {
        if (request.getHeader(RESTHandlerContainer.COLLECTIVE_HOST_NAMES) != null) {
            return true;
        }

        //No routing header found, so check query strings
        return getQueryParameterValue(request, RESTHandlerContainer.COLLECTIVE_HOST_NAMES) != null;
    }
111778
protected void preOperation(AipRequest request) {
        if (needAuth()) {
            getAccessToken(config);
        }

        request.setHttpMethod(HttpMethodName.POST);
        request.addHeader(Headers.CONTENT_TYPE, HttpContentType.FORM_URLENCODE_DATA);
        request.addHeader("accept", "*/*");
        request.setConfig(config);
    }
564578
public boolean matches(Request req) {
        if (!method.equals(req.getMethod())) return false;
        if (useRegexForPath) {
            if (!req.getPath().getPath().matches(basePath)) return false;
        } else {
            if (!basePath.equals(req.getPath().getPath())) return false;
        }
        if (!queries.keySet().containsAll(req.getQuery().keySet())) return false;
        if (!req.getNames().containsAll(headers.keySet())) return false;

        try {
            if (!isEmpty(bodyMustContain) && !req.getContent().contains(bodyMustContain))
                return false;
        } catch (IOException e) {
            return false;
        }

        for (Map.Entry<String, String> reqQuery : req.getQuery().entrySet()) {
            String respRegex = queries.get(reqQuery.getKey());
            if (!reqQuery.getValue().matches(respRegex)) return false;
        }
        for(Map.Entry<String, String> header : headers.entrySet()) {
            String headerValueRegex = header.getValue();
            if(!req.getValue(header.getKey()).matches(headerValueRegex)) return false;
        }
        return true;
    }