|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* Copyright 2002-2020 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. |
|
|
|
@ -38,6 +38,7 @@ import io.undertow.util.HeaderMap; |
|
|
|
import io.undertow.util.HttpString; |
|
|
|
import io.undertow.util.HttpString; |
|
|
|
import io.undertow.util.Methods; |
|
|
|
import io.undertow.util.Methods; |
|
|
|
import io.undertow.util.StringReadChannelListener; |
|
|
|
import io.undertow.util.StringReadChannelListener; |
|
|
|
|
|
|
|
import org.springframework.util.StreamUtils; |
|
|
|
import org.xnio.ChannelListener; |
|
|
|
import org.xnio.ChannelListener; |
|
|
|
import org.xnio.ChannelListeners; |
|
|
|
import org.xnio.ChannelListeners; |
|
|
|
import org.xnio.IoUtils; |
|
|
|
import org.xnio.IoUtils; |
|
|
|
@ -405,8 +406,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport { |
|
|
|
throw new SockJsException("Session closed.", this.session.getId(), null); |
|
|
|
throw new SockJsException("Session closed.", this.session.getId(), null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PooledByteBuffer pooled = bufferPool.allocate(); |
|
|
|
try (PooledByteBuffer pooled = bufferPool.allocate()) { |
|
|
|
try { |
|
|
|
|
|
|
|
int r; |
|
|
|
int r; |
|
|
|
do { |
|
|
|
do { |
|
|
|
ByteBuffer buffer = pooled.getBuffer(); |
|
|
|
ByteBuffer buffer = pooled.getBuffer(); |
|
|
|
@ -436,20 +436,16 @@ public class UndertowXhrTransport extends AbstractXhrTransport { |
|
|
|
catch (IOException exc) { |
|
|
|
catch (IOException exc) { |
|
|
|
onFailure(exc); |
|
|
|
onFailure(exc); |
|
|
|
} |
|
|
|
} |
|
|
|
finally { |
|
|
|
|
|
|
|
pooled.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handleFrame() { |
|
|
|
private void handleFrame() { |
|
|
|
byte[] bytes = this.outputStream.toByteArray(); |
|
|
|
String content = StreamUtils.baosToString(this.outputStream, SockJsFrame.CHARSET); |
|
|
|
this.outputStream.reset(); |
|
|
|
this.outputStream.reset(); |
|
|
|
String content = new String(bytes, SockJsFrame.CHARSET); |
|
|
|
|
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
logger.trace("XHR content received: " + content); |
|
|
|
logger.trace("XHR content received: " + content); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!PRELUDE.equals(content)) { |
|
|
|
if (!PRELUDE.equals(content)) { |
|
|
|
this.session.handleFrame(new String(bytes, SockJsFrame.CHARSET)); |
|
|
|
this.session.handleFrame(content); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|