Consistent and lenient HttpMethod resolution across all web modules
Issue: SPR-13776
This commit is contained in:
@@ -231,7 +231,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
logger.trace("Processing request " + request.getURI() + " with headers=" + headers);
|
||||
}
|
||||
try {
|
||||
if (!HttpMethod.GET.equals(request.getMethod())) {
|
||||
if (HttpMethod.GET != request.getMethod()) {
|
||||
response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
|
||||
response.getHeaders().setAllow(Collections.singleton(HttpMethod.GET));
|
||||
if (logger.isErrorEnabled()) {
|
||||
@@ -320,8 +320,8 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
". Supported versions: " + Arrays.toString(getSupportedVersions()));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.UPGRADE_REQUIRED);
|
||||
response.getHeaders().put(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION,
|
||||
Arrays.asList(StringUtils.arrayToCommaDelimitedString(getSupportedVersions())));
|
||||
response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION,
|
||||
StringUtils.arrayToCommaDelimitedString(getSupportedVersions()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -544,7 +544,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||
|
||||
@Override
|
||||
public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
|
||||
if (HttpMethod.GET.equals(request.getMethod())) {
|
||||
if (HttpMethod.GET == request.getMethod()) {
|
||||
addNoCacheHeaders(response);
|
||||
if (checkOrigin(request, response)) {
|
||||
response.getHeaders().setContentType(new MediaType("application", "json", UTF8_CHARSET));
|
||||
@@ -554,7 +554,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||
}
|
||||
|
||||
}
|
||||
else if (HttpMethod.OPTIONS.equals(request.getMethod())) {
|
||||
else if (HttpMethod.OPTIONS == request.getMethod()) {
|
||||
if (checkOrigin(request, response)) {
|
||||
addCacheHeaders(response);
|
||||
response.setStatusCode(HttpStatus.NO_CONTENT);
|
||||
|
||||
@@ -247,8 +247,8 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
|
||||
try {
|
||||
HttpMethod supportedMethod = transportType.getHttpMethod();
|
||||
if (!supportedMethod.equals(request.getMethod())) {
|
||||
if (HttpMethod.OPTIONS.equals(request.getMethod()) && transportType.supportsCors()) {
|
||||
if (supportedMethod != request.getMethod()) {
|
||||
if (HttpMethod.OPTIONS == request.getMethod() && transportType.supportsCors()) {
|
||||
if (checkOrigin(request, response, HttpMethod.OPTIONS, supportedMethod)) {
|
||||
response.setStatusCode(HttpStatus.NO_CONTENT);
|
||||
addCacheHeaders(response);
|
||||
|
||||
Reference in New Issue
Block a user