Explicit HEAD sorted higher than implicit one

Same fix as #7cdcc1 but for WebFlux.

Issue: SPR-14182
This commit is contained in:
Rossen Stoyanchev
2019-01-02 09:23:05 -05:00
parent 72fbbb2403
commit 1cb9f2c7b2
3 changed files with 28 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ public class RequestMethodsRequestConditionTests {
@Test
public void getMatchingConditionWithHttpHead() throws Exception {
testMatch(new RequestMethodsRequestCondition(HEAD), HEAD);
testMatch(new RequestMethodsRequestCondition(GET), HEAD);
testMatch(new RequestMethodsRequestCondition(GET), GET);
testNoMatch(new RequestMethodsRequestCondition(POST), HEAD);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@ import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import org.springframework.web.server.adapter.ForwardedHeaderTransformer;
@@ -100,10 +102,16 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
private static class TestRestController {
@GetMapping("/text")
public String text() {
public String textGet() {
return "Foo";
}
// SPR-17593: explicit HEAD should not clash with implicit mapping via GET
@RequestMapping(path = "/text", method = RequestMethod.HEAD)
public String textHead() {
return textGet();
}
@GetMapping("/uri")
public String uri(ServerHttpRequest request) {
return request.getURI().toString();