当前位置: 首页>>代码示例>>Java>>正文


Java CorsUtils.isCorsRequest方法代码示例

本文整理汇总了Java中org.springframework.web.cors.CorsUtils.isCorsRequest方法的典型用法代码示例。如果您正苦于以下问题:Java CorsUtils.isCorsRequest方法的具体用法?Java CorsUtils.isCorsRequest怎么用?Java CorsUtils.isCorsRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.cors.CorsUtils的用法示例。


在下文中一共展示了CorsUtils.isCorsRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFilterInternal

import org.springframework.web.cors.CorsUtils; //导入方法依赖的package包/类
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    if (corsEnabled) {
        if (CorsUtils.isCorsRequest(request)) {
            response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, defaultIfBlank(request.getHeader(ORIGIN), "*"));
            response.setHeader(ACCESS_CONTROL_ALLOW_METHODS, defaultIfBlank(request.getHeader(ACCESS_CONTROL_REQUEST_METHOD),
                    "HEAD, POST, PUT, GET, OPTIONS, DELETE"));
            response.setHeader(ACCESS_CONTROL_ALLOW_HEADERS, defaultIfBlank(request.getHeader(ACCESS_CONTROL_REQUEST_HEADERS),
                    join(new String[]{CONTENT_TYPE, ACCEPT}, ',')));
            response.setHeader(ACCESS_CONTROL_EXPOSE_HEADERS, LOCATION);
            response.setHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
            response.setHeader(ACCESS_CONTROL_MAX_AGE, "3601");
        }

        if (!CorsUtils.isPreFlightRequest(request)) {
            filterChain.doFilter(request, response);
        }
    } else {
        super.doFilterInternal(request, response, filterChain);
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:22,代码来源:CorsFilter.java

示例2: getHandler

import org.springframework.web.cors.CorsUtils; //导入方法依赖的package包/类
/**
 * Look up a handler for the given request, falling back to the default
 * handler if no specific one is found.
 * @param request current HTTP request
 * @return the corresponding handler instance, or the default handler
 * @see #getHandlerInternal
 */
@Override
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception {
	Object handler = getHandlerInternal(request);
	if (handler == null) {
		handler = getDefaultHandler();
	}
	if (handler == null) {
		return null;
	}
	// Bean name or resolved handler?
	if (handler instanceof String) {
		String handlerName = (String) handler;
		handler = getApplicationContext().getBean(handlerName);
	}

	HandlerExecutionChain executionChain = getHandlerExecutionChain(handler, request);
	if (CorsUtils.isCorsRequest(request)) {
		CorsConfiguration globalConfig = this.corsConfigSource.getCorsConfiguration(request);
		CorsConfiguration handlerConfig = getCorsConfiguration(handler, request);
		CorsConfiguration config = (globalConfig != null ? globalConfig.combine(handlerConfig) : handlerConfig);
		executionChain = getCorsHandlerExecutionChain(request, executionChain, config);
	}
	return executionChain;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:AbstractHandlerMapping.java

示例3: incomingRequestPreProcessed

import org.springframework.web.cors.CorsUtils; //导入方法依赖的package包/类
@Override
public boolean incomingRequestPreProcessed(HttpServletRequest theRequest, HttpServletResponse theResponse) {
	if (CorsUtils.isCorsRequest(theRequest)) {
		boolean isValid;
		try {
			isValid = myCorsProcessor.processRequest(myConfig, theRequest, theResponse);
		} catch (IOException e) {
			throw new InternalErrorException(e);
		}
		if (!isValid || CorsUtils.isPreFlightRequest(theRequest)) {
			return false;
		}
	}

	return super.incomingRequestPreProcessed(theRequest, theResponse);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:CorsInterceptor.java

示例4: getCorsConfiguration

import org.springframework.web.cors.CorsUtils; //导入方法依赖的package包/类
@Override
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
	if (!this.suppressCors && CorsUtils.isCorsRequest(request)) {
		CorsConfiguration config = new CorsConfiguration();
		config.addAllowedOrigin("*");
		config.addAllowedMethod("*");
		config.setAllowCredentials(true);
		config.setMaxAge(ONE_YEAR);
		config.addAllowedHeader("*");
		return config;
	}
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:AbstractSockJsService.java

示例5: doFilterInternal

import org.springframework.web.cors.CorsUtils; //导入方法依赖的package包/类
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
		FilterChain filterChain) throws ServletException, IOException {

	if (CorsUtils.isCorsRequest(request)) {
		CorsConfiguration corsConfiguration = this.configSource.getCorsConfiguration(request);
		if (corsConfiguration != null) {
			boolean isValid = this.processor.processRequest(corsConfiguration, request, response);
			if (!isValid || CorsUtils.isPreFlightRequest(request)) {
				return;
			}
		}
	}
	filterChain.doFilter(request, response);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:CorsFilter.java


注:本文中的org.springframework.web.cors.CorsUtils.isCorsRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。