Add formatting for SockJS GoAway frame

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

See gh-28000
This commit is contained in:
Ivan Zbykovskyi
2022-02-03 13:34:02 +02:00
committed by rstoyanchev
parent 88f73bffa0
commit f004bb1b64
2 changed files with 5 additions and 2 deletions

View File

@@ -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);

View File

@@ -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;