Browse Source

Add formatting for SockJS GoAway frame

Prevents infinite loop for xhr-polling and xhr-streaming transports.

See gh-28000
pull/28119/head
Ivan Zbykovskyi 3 years ago committed by rstoyanchev
parent
commit
f004bb1b64
  1. 4
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java
  2. 3
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java

4
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpSendingTransportHandler.java

@ -79,9 +79,11 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp @@ -79,9 +79,11 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
if (logger.isDebugEnabled()) {
logger.debug("Connection already closed (but not removed yet) for " + sockJsSession);
}
SockJsFrameFormat frameFormat = this.getFrameFormat(request);
SockJsFrame frame = SockJsFrame.closeFrameGoAway();
String formattedFrame = frameFormat.format(frame);
try {
response.getBody().write(frame.getContentBytes());
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
}
catch (IOException ex) {
throw new SockJsException("Failed to send " + frame, sockJsSession.getId(), ex);

3
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java

@ -257,7 +257,8 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession { @@ -257,7 +257,8 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
synchronized (this.responseLock) {
try {
if (isClosed()) {
response.getBody().write(SockJsFrame.closeFrameGoAway().getContentBytes());
String formattedFrame = frameFormat.format(SockJsFrame.closeFrameGoAway());
response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
return;
}
this.response = response;

Loading…
Cancel
Save