Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public abstract class BasicConfiguration {
protected boolean httpCompression = true;

protected boolean websocketCompression = true;
protected int decompressionBufferSize = 0;


protected boolean randomSession = false;

Expand Down Expand Up @@ -135,6 +137,7 @@ protected BasicConfiguration(BasicConfiguration conf) {

setHttpCompression(conf.isHttpCompression());
setWebsocketCompression(conf.isWebsocketCompression());
setDecompressionBufferSize(conf.getDecompressionBufferSize());
setRandomSession(conf.randomSession);
setNeedClientAuth(conf.isNeedClientAuth());
setMetrics(conf.getMetrics());
Expand Down Expand Up @@ -452,6 +455,25 @@ public void setWebsocketCompression(boolean websocketCompression) {
this.websocketCompression = websocketCompression;
}

public int getDecompressionBufferSize() {
return decompressionBufferSize;
}

/**
* Set the maximum decompression buffer size for WebSocket compression.
* Used to limit memory consumption during WebSocket message decompression.
* <p>
* Default is <code>0</code> which means unlimited
*
* `@param` decompressionBufferSize - buffer size in bytes, or 0 for [unlimited/default]
*/
public void setDecompressionBufferSize(int decompressionBufferSize) {
if (decompressionBufferSize < 0) {
throw new IllegalArgumentException("decompressionBufferSize must be non-negative");
}
this.decompressionBufferSize = decompressionBufferSize;
}

public boolean isWebsocketCompression() {
return websocketCompression;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected Object newContinueResponse(HttpMessage start, int maxContentLength,
pipeline.addLast(AUTHORIZE_HANDLER, authorizeHandler);
pipeline.addLast(XHR_POLLING_TRANSPORT, xhrPollingTransport);
if (configuration.isWebsocketCompression()) {
pipeline.addLast(WEB_SOCKET_TRANSPORT_COMPRESSION, new WebSocketServerCompressionHandler());
pipeline.addLast(WEB_SOCKET_TRANSPORT_COMPRESSION, new WebSocketServerCompressionHandler(configuration.getDecompressionBufferSize()));
}
pipeline.addLast(WEB_SOCKET_TRANSPORT, webSocketTransport);

Expand Down
Loading