org.springframework.http.HttpMethod.OPTIONS

Here are the examples of the java api org.springframework.http.HttpMethod.OPTIONS taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

286 Examples 7

19 Source : RequestPredicates.java
with MIT License
from Vip-Augus

/**
 * Return a {@code RequestPredicate} that matches if request's HTTP method is {@code OPTIONS}
 * and the given {@code pattern} matches against the request path.
 * @param pattern the path pattern to match against
 * @return a predicate that matches if the request method is OPTIONS and if the given pattern
 * matches against the request path
 */
public static RequestPredicate OPTIONS(String pattern) {
    return method(HttpMethod.OPTIONS).and(path(pattern));
}

19 Source : DefaultCorsProcessorTests.java
with MIT License
from Vip-Augus

private MockServerHttpRequest.BaseBuilder<?> preFlightRequest() {
    return corsRequest(HttpMethod.OPTIONS);
}

19 Source : MockServerHttpRequest.java
with MIT License
from Vip-Augus

/**
 * HTTP OPTIONS variant. See {@link #get(String, Object...)} for general info.
 * @param urlTemplate a URL template; the resulting URL will be encoded
 * @param uriVars zero or more URI variables
 * @return the created builder
 */
public static BaseBuilder<?> options(String urlTemplate, Object... uriVars) {
    return method(HttpMethod.OPTIONS, urlTemplate, uriVars);
}

18 Source : WebContentGenerator.java
with MIT License
from Vip-Augus

private void initAllowHeader() {
    Collection<String> allowedMethods;
    if (this.supportedMethods == null) {
        allowedMethods = new ArrayList<>(HttpMethod.values().length - 1);
        for (HttpMethod method : HttpMethod.values()) {
            if (method != HttpMethod.TRACE) {
                allowedMethods.add(method.name());
            }
        }
    } else if (this.supportedMethods.contains(HttpMethod.OPTIONS.name())) {
        allowedMethods = this.supportedMethods;
    } else {
        allowedMethods = new ArrayList<>(this.supportedMethods);
        allowedMethods.add(HttpMethod.OPTIONS.name());
    }
    this.allowHeader = StringUtils.collectionToCommaDelimitedString(allowedMethods);
}

18 Source : DefaultWebClient.java
with MIT License
from Vip-Augus

@Override
public RequestHeadersUriSpec<?> options() {
    return methodInternal(HttpMethod.OPTIONS);
}

18 Source : RestTemplate.java
with MIT License
from Vip-Augus

@Override
public Set<HttpMethod> optionsForAllow(String url, Map<String, ?> uriVariables) throws RestClientException {
    ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, headersExtractor, uriVariables);
    return (headers != null ? headers.getAllow() : Collections.emptySet());
}

18 Source : RestTemplate.java
with MIT License
from Vip-Augus

// OPTIONS
@Override
public Set<HttpMethod> optionsForAllow(String url, Object... uriVariables) throws RestClientException {
    ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, headersExtractor, uriVariables);
    return (headers != null ? headers.getAllow() : Collections.emptySet());
}

18 Source : MockMvcSupport.java
with Apache License 2.0
from ch4mpy

/* OPTION */
/**
 * Factory for an OPTION request initialized with an Accept header.
 *
 * @param accept      response body media-type
 * @param urlTemplate API end-point
 * @param uriVars     values for end-point URL placeholders
 * @return request builder to be further configured (additional headers,
 *         cookies, etc.)
 */
public MockHttpServletRequestBuilder optionRequestBuilder(MediaType accept, String urlTemplate, Object... uriVars) {
    return requestBuilder(Optional.of(accept), Optional.empty(), HttpMethod.OPTIONS, urlTemplate, uriVars);
}

18 Source : Options.java
with Apache License 2.0
from beifei1

@Override
protected List<HttpMethod> supportMethods() {
    return Lists.newArrayList(HttpMethod.OPTIONS);
}

17 Source : RequestMappingInfoHandlerMappingTests.java
with MIT License
from Vip-Augus

@Test
public void getHandlerHttpOptions() {
    List<HttpMethod> allMethodExceptTrace = new ArrayList<>(Arrays.asList(HttpMethod.values()));
    allMethodExceptTrace.remove(HttpMethod.TRACE);
    testHttpOptions("/foo", EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
    testHttpOptions("/person/1", EnumSet.of(HttpMethod.PUT, HttpMethod.OPTIONS));
    testHttpOptions("/persons", EnumSet.copyOf(allMethodExceptTrace));
    testHttpOptions("/something", EnumSet.of(HttpMethod.PUT, HttpMethod.POST));
}

17 Source : CorsUrlHandlerMappingTests.java
with MIT License
from Vip-Augus

@Test
public void preflightRequestWithoutCorsConfigurationProvider() throws Exception {
    String origin = "https://domain2.com";
    ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/welcome.html", origin);
    Object actual = this.handlerMapping.getHandler(exchange).block();
    replacedertNotNull(actual);
    replacedertSame(this.welcomeController, actual);
}

17 Source : RestTemplateIntegrationTests.java
with MIT License
from Vip-Augus

@Test
public void optionsForAllow() throws URISyntaxException {
    Set<HttpMethod> allowed = template.optionsForAllow(new URI(baseUrl + "/get"));
    replacedertEquals("Invalid response", EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE), allowed);
}

17 Source : RestTemplate.java
with MIT License
from Vip-Augus

@Override
public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
    ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, headersExtractor);
    return (headers != null ? headers.getAllow() : Collections.emptySet());
}

17 Source : AsyncRestTemplate.java
with MIT License
from Vip-Augus

@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Map<String, ?> uriVars) throws RestClientException {
    ResponseExtractor<HttpHeaders> extractor = headersExtractor();
    ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.OPTIONS, null, extractor, uriVars);
    return adaptToAllowHeader(future);
}

17 Source : AsyncRestTemplate.java
with MIT License
from Vip-Augus

// OPTIONS
@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Object... uriVars) throws RestClientException {
    ResponseExtractor<HttpHeaders> extractor = headersExtractor();
    ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.OPTIONS, null, extractor, uriVars);
    return adaptToAllowHeader(future);
}

17 Source : CorsUrlHandlerMappingTests.java
with Apache License 2.0
from SourceHot

@Test
public void preflightRequestWithoutCorsConfigurationProvider() throws Exception {
    String origin = "https://domain2.com";
    ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/welcome.html", origin);
    Object actual = this.handlerMapping.getHandler(exchange).block();
    replacedertThat(actual).isNotNull();
    replacedertThat(actual).isNotSameAs(this.welcomeController);
}

17 Source : SecurityJwtConfiguration.java
with GNU Lesser General Public License v3.0
from somowhere

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/statics/**").antMatchers("/replacedets/**/*.{js,html}").antMatchers("/test/**");
}

17 Source : SecurityAutoConfiguration.java
with GNU Lesser General Public License v3.0
from somowhere

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/webjars/**").antMatchers("/**/*.{js,html}");
}

17 Source : AuthAuthorizeConfigProvider.java
with Apache License 2.0
from open-capacity-platform

@Override
public boolean config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
    // 免token登录设置
    config.antMatchers(permitUrlProperties.getIgnored()).permitAll();
    // 前后分离时需要带上
    config.antMatchers(HttpMethod.OPTIONS).permitAll();
    return true;
}

17 Source : AsyncRestTemplate.java
with Apache License 2.0
from langtianya

@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Map<String, ?> uriVariables) throws RestClientException {
    ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
    ListenableFuture<HttpHeaders> headersFuture = execute(url, HttpMethod.OPTIONS, null, headersExtractor, uriVariables);
    return extractAllowHeader(headersFuture);
}

17 Source : AsyncRestTemplate.java
with Apache License 2.0
from langtianya

// OPTIONS
@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(String url, Object... uriVariables) throws RestClientException {
    ResponseExtractor<HttpHeaders> headersExtractor = headersExtractor();
    ListenableFuture<HttpHeaders> headersFuture = execute(url, HttpMethod.OPTIONS, null, headersExtractor, uriVariables);
    return extractAllowHeader(headersFuture);
}

17 Source : SecurityConfiguration.java
with Apache License 2.0
from epam

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.requestMatcher(getFullRequestMatcher());
    http.httpBasic().authenticationEntryPoint(samlEntryPoint());
    http.csrf().disable();
    http.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.clreplaced).addFilterAfter(samlFilter(), BasicAuthenticationFilter.clreplaced);
    http.authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers(SECURED_RESOURCES_ROOT).authenticated().antMatchers("/saml/web/**").permitAll();
    http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED);
    http.logout().logoutSuccessUrl("/");
}

16 Source : TraderBrokerSecurityConfiguration.java
with Apache License 2.0
from zhugf

/*
     * 开放 Options 请求
     */
@Override
public void configure(WebSecurity web) throws Exception {
    // TODO Auto-generated method stub
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from yodamad

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/h2-console/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
// .antMatchers("/api/gitlab/**");
}

16 Source : UaaWebSecurityConfiguration.java
with Apache License 2.0
from xm-online

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/bower_components/**").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**").antMatchers("/h2-console/**");
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from xebialabs

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/h2-console/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from xebialabs

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from xebialabs

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/h2-console/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : JWTSecurityConfiguration.java
with Apache License 2.0
from viz-centric

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/swagger-ui/**").antMatchers("/content/**");
}

16 Source : StatelessBasicAuthenticationSecurityConfiguration.java
with Apache License 2.0
from viz-centric

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}

16 Source : JwtSecurityConfiguration.java
with Apache License 2.0
from viz-centric

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : CorsUrlHandlerMappingTests.java
with MIT License
from Vip-Augus

@Test
public void preFlightWithCorsAwareHandler() throws Exception {
    String origin = "https://domain2.com";
    ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/cors.html", origin);
    Object actual = this.handlerMapping.getHandler(exchange).block();
    replacedertNotNull(actual);
    replacedertNotSame(this.corsController, actual);
    replacedertEquals("*", exchange.getResponse().getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}

16 Source : AsyncRestTemplateIntegrationTests.java
with MIT License
from Vip-Augus

@Test
public void optionsForAllow() throws Exception {
    Future<Set<HttpMethod>> allowedFuture = template.optionsForAllow(new URI(baseUrl + "/get"));
    Set<HttpMethod> allowed = allowedFuture.get();
    replacedertEquals("Invalid response", EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE), allowed);
}

16 Source : AsyncRestTemplateIntegrationTests.java
with MIT License
from Vip-Augus

@Test
public void optionsForAllowCallbackWithLambdas() throws Exception {
    ListenableFuture<Set<HttpMethod>> allowedFuture = template.optionsForAllow(new URI(baseUrl + "/get"));
    allowedFuture.addCallback(result -> replacedertEquals("Invalid response", EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE), result), ex -> fail(ex.getMessage()));
    waitTillDone(allowedFuture);
}

16 Source : AsyncRestTemplate.java
with MIT License
from Vip-Augus

@Override
public ListenableFuture<Set<HttpMethod>> optionsForAllow(URI url) throws RestClientException {
    ResponseExtractor<HttpHeaders> extractor = headersExtractor();
    ListenableFuture<HttpHeaders> future = execute(url, HttpMethod.OPTIONS, null, extractor);
    return adaptToAllowHeader(future);
}

16 Source : WebSecurityConfig.java
with Apache License 2.0
from TNG

@Override
protected void configure(final HttpSecurity http) throws Exception {
    super.configure(http);
    http.authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll().antMatchers("/api/**").authenticated().antMatchers("/**").permitAll();
}

16 Source : AuthConfig.java
with Apache License 2.0
from tmobile

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(AUTH_WHITELIST);
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
}

16 Source : WebSecurityConfig.java
with Apache License 2.0
from tmobile

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**");
    web.ignoring().antMatchers("/auth/api.html", "/actuator/**", "/imgs/**", "/css/**", "/hystrix/monitor/**", "/hystrix/**", "/public/**", "/swagger-ui.html", "/api.html", "/js/swagger-oauth.js", "/images/pacman_logo.svg", "/js/swagger.js", "/js/swagger-ui.js", "/images/favicon-32x32.png", "/images/favicon-16x16.png", "/images/favicon.ico", "/swagger-resources/**", "/v2/api-docs/**", "/webjars/**", "/v1/auth/**", "/client-auth/**", "/user/login/**", "/auth/refresh/**", "/user/authorize/**", "/user/refresh/**");
}

16 Source : AuthConfig.java
with Apache License 2.0
from tmobile

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers(AUTH_WHITELIST);
    web.ignoring().antMatchers("/actuator/**");
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**", "/actuator/**");
}

16 Source : ResourceConfig.java
with MIT License
from tinmegali

@Override
public void configure(HttpSecurity http) throws Exception {
    http.requestMatcher(new OAuthRequestedMatcher()).csrf().disable().anonymous().disable().authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers("/api/hello").access("hasAnyRole('USER')").antMatchers("/api/me").hasAnyRole("USER", "ADMIN").antMatchers("/api/admin").hasRole("ADMIN").antMatchers("/api/registerUser").hasAuthority("ROLE_REGISTER").antMatchers("/api/**").authenticated();
}

16 Source : SecurityConfig.java
with MIT License
from tinmegali

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().anyRequest().authenticated().antMatchers("/", "/**").permitAll().antMatchers(HttpMethod.OPTIONS).permitAll().and().httpBasic().and().csrf().disable();
}

16 Source : ResourceConfig.java
with MIT License
from tinmegali

@Override
public void configure(HttpSecurity http) throws Exception {
    http.requestMatcher(new OAuthRequestedMatcher()).anonymous().disable().authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().antMatchers("/api/hello").access("hasAnyRole('USER')").antMatchers("/api/me").hasAnyRole("USER", "ADMIN").antMatchers("/api/register").hasAuthority("ROLE_REGISTER");
}

16 Source : SecurityConfiguration.java
with MIT License
from tillias

@Override
public void configure(WebSecurity web) {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/h2-console/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from suricate-io

/**
 * Global Security
 */
@Override
public void configure(WebSecurity web) {
    web.expressionHandler(defaultWebSecurityExpressionHandler()).ignoring().antMatchers(HttpMethod.OPTIONS);
}

16 Source : PathMatcherServerWebExchangeMatcherTests.java
with Apache License 2.0
from spring-projects

@Test
public void matchesWhenPathMatcherTrueAndMethodFalseThenReturnFalse() {
    HttpMethod method = HttpMethod.OPTIONS;
    replacedertThat(exchange.getRequest().getMethod()).isNotEqualTo(method);
    matcher = new PathMatcherServerWebExchangeMatcher(pattern, method);
    matcher.setPathMatcher(pathMatcher);
    replacedertThat(matcher.matches(exchange).isMatch()).isFalse();
    verifyZeroInteractions(pathMatcher);
}

16 Source : CorsUrlHandlerMappingTests.java
with Apache License 2.0
from SourceHot

@Test
public void preFlightWithCorsAwareHandler() throws Exception {
    String origin = "https://domain2.com";
    ServerWebExchange exchange = createExchange(HttpMethod.OPTIONS, "/cors.html", origin);
    Object actual = this.handlerMapping.getHandler(exchange).block();
    replacedertThat(actual).isNotNull();
    replacedertThat(actual).isNotSameAs(this.corsController);
    replacedertThat(exchange.getResponse().getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)).isEqualTo("*");
}

16 Source : SophiaWebSecurityConfig.java
with Apache License 2.0
from SophiaLeo

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.requestMatchers().anyRequest().and().authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll().antMatchers(securityProperties.getWeb().getUnInterceptUris()).permitAll().and().authorizeRequests().anyRequest().authenticated().and().csrf().disable();
}

16 Source : SecurityConfiguration.java
with Apache License 2.0
from RansongZ

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll().anyRequest().authenticated().and().httpBasic().and().csrf().disable();
}

16 Source : SecurityConfiguration.java
with MIT License
from puzzle

@Override
public void configure(WebSecurity web) {
    web.ignoring().antMatchers(HttpMethod.OPTIONS, "/**").antMatchers("/app/**/*.{js,html}").antMatchers("/i18n/**").antMatchers("/content/**").antMatchers("/swagger-ui/index.html").antMatchers("/test/**");
}

16 Source : OAuth2ResourceServerConfig.java
with MIT License
from PacktPublishing

@Override
public void configure(final HttpSecurity http) throws Exception {
    // Allow AJAX preflight requests via HttpMethod.OPTIONS to be made without
    http.authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
}

See More Examples