Polishing
This commit is contained in:
parent
0c2b787cb5
commit
491adf1f2f
|
@ -55,11 +55,11 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||||
|
|
||||||
private static final String METHOD_HEAD = "HEAD";
|
private static final String METHOD_HEAD = "HEAD";
|
||||||
|
|
||||||
|
|
||||||
/** Checking for Servlet 3.0+ HttpServletResponse.getStatus() */
|
/** Checking for Servlet 3.0+ HttpServletResponse.getStatus() */
|
||||||
private static final boolean responseGetStatusAvailable =
|
private static final boolean responseGetStatusAvailable =
|
||||||
ClassUtils.hasMethod(HttpServletResponse.class, "getStatus");
|
ClassUtils.hasMethod(HttpServletResponse.class, "getStatus");
|
||||||
|
|
||||||
|
|
||||||
private boolean notModified = false;
|
private boolean notModified = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,12 +193,6 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||||
return this.notModified;
|
return this.notModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCompatibleWithConditionalRequests(HttpServletResponse response) {
|
|
||||||
return response == null
|
|
||||||
|| !responseGetStatusAvailable
|
|
||||||
|| HttpStatus.valueOf(response.getStatus()).is2xxSuccessful();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private boolean isTimestampNotModified(long lastModifiedTimestamp) {
|
private boolean isTimestampNotModified(long lastModifiedTimestamp) {
|
||||||
long ifModifiedSince = -1;
|
long ifModifiedSince = -1;
|
||||||
|
@ -242,6 +236,14 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||||
return this.notModified;
|
return this.notModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isCompatibleWithConditionalRequests(HttpServletResponse response) {
|
||||||
|
if (response == null || !responseGetStatusAvailable) {
|
||||||
|
// Can't check response.getStatus() - let's assume we're good
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return HttpStatus.valueOf(response.getStatus()).is2xxSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
private String addEtagPadding(String etag) {
|
private String addEtagPadding(String etag) {
|
||||||
if (!(etag.startsWith("\"") || etag.startsWith("W/\"")) || !etag.endsWith("\"")) {
|
if (!(etag.startsWith("\"") || etag.startsWith("W/\"")) || !etag.endsWith("\"")) {
|
||||||
etag = "\"" + etag + "\"";
|
etag = "\"" + etag + "\"";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -88,7 +88,7 @@ public class WebSphereRequestUpgradeStrategy extends AbstractStandardUpgradeStra
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new HandshakeFailureException(
|
throw new HandshakeFailureException(
|
||||||
"Servlet request failed to upgrade to WebSocket, uri=" + requestUrl, ex);
|
"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,13 +76,13 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||||
private static final boolean undertowWsPresent = ClassUtils.isPresent(
|
private static final boolean undertowWsPresent = ClassUtils.isPresent(
|
||||||
"io.undertow.websockets.jsr.ServerWebSocketContainer", classLoader);
|
"io.undertow.websockets.jsr.ServerWebSocketContainer", classLoader);
|
||||||
|
|
||||||
private static final boolean glassFishWsPresent = ClassUtils.isPresent(
|
private static final boolean glassfishWsPresent = ClassUtils.isPresent(
|
||||||
"org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", classLoader);
|
"org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", classLoader);
|
||||||
|
|
||||||
private static final boolean webLogicWsPresent = ClassUtils.isPresent(
|
private static final boolean weblogicWsPresent = ClassUtils.isPresent(
|
||||||
"weblogic.websocket.tyrus.TyrusServletWriter", classLoader);
|
"weblogic.websocket.tyrus.TyrusServletWriter", classLoader);
|
||||||
|
|
||||||
private static final boolean webSphereWsPresent = ClassUtils.isPresent(
|
private static final boolean websphereWsPresent = ClassUtils.isPresent(
|
||||||
"com.ibm.websphere.wsoc.WsWsocServerContainer", classLoader);
|
"com.ibm.websphere.wsoc.WsWsocServerContainer", classLoader);
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,13 +125,13 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||||
else if (undertowWsPresent) {
|
else if (undertowWsPresent) {
|
||||||
className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
|
className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
|
||||||
}
|
}
|
||||||
else if (glassFishWsPresent) {
|
else if (glassfishWsPresent) {
|
||||||
className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
|
className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
|
||||||
}
|
}
|
||||||
else if (webLogicWsPresent) {
|
else if (weblogicWsPresent) {
|
||||||
className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
|
className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
|
||||||
}
|
}
|
||||||
else if (webSphereWsPresent) {
|
else if (websphereWsPresent) {
|
||||||
className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
|
className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -368,7 +368,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the list of requested WebSocket extensions.
|
* Filter the list of requested WebSocket extensions.
|
||||||
* <p>As of 4.1 the default implementation of this method filters the list to
|
* <p>As of 4.1, the default implementation of this method filters the list to
|
||||||
* leave only extensions that are both requested and supported.
|
* leave only extensions that are both requested and supported.
|
||||||
* @param request the current request
|
* @param request the current request
|
||||||
* @param requestedExtensions the list of extensions requested by the client
|
* @param requestedExtensions the list of extensions requested by the client
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy;
|
||||||
*/
|
*/
|
||||||
public class DefaultHandshakeHandler extends AbstractHandshakeHandler implements ServletContextAware {
|
public class DefaultHandshakeHandler extends AbstractHandshakeHandler implements ServletContextAware {
|
||||||
|
|
||||||
|
|
||||||
public DefaultHandshakeHandler() {
|
public DefaultHandshakeHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue