public void tagRequest ( final HttpServletRequest request ) { final CORSRequestType type = CORSRequestType . detect ( request ) ; switch ( type ) { case ACTUAL : request . setAttribute ( "cors.isCorsRequest" , true ) ; request . setAttribute ( "cors.origin" , request . getHeader ( "Origin" ) ) ; request . setAttribute ( "cors.requestType" , "actual" ) ; break ; case PREFLIGHT : request . setAttribute ( "cors.isCorsRequest" , true ) ; request . setAttribute ( "cors.origin" , request . getHeader ( "Origin" ) ) ; request . setAttribute ( "cors.requestType" , "preflight" ) ; request . setAttribute ( "cors.requestHeaders" , request . getHeader ( "Access-Control-Request-Headers" ) ) ; break ; case OTHER : request . setAttribute ( "cors.isCorsRequest" , false ) ; } }
Tags an HTTP servlet request to provide CORS information to downstream handlers .