Merge pull request #302 from Panke/fix-receivebuffer-length

fix(http2): increase receivebuffer.length
This commit is contained in:
Adam D. Ruppe 2021-09-18 07:30:46 -04:00 committed by GitHub
commit 9ce96cfdbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -3540,6 +3540,15 @@ class WebSocket {
public bool lowLevelReceive() {
if(readyState == CONNECTING)
throw new Exception("WebSocket not connected when trying to receive. Did you forget to call connect(); ?");
if (receiveBufferUsedLength == receiveBuffer.length)
{
if (receiveBuffer.length == config.maximumReceiveBufferSize)
throw new Exception("Maximum receive buffer size exhausted");
import std.algorithm : min;
receiveBuffer.length = min(receiveBuffer.length + config.initialReceiveBufferSize,
config.maximumReceiveBufferSize);
}
auto r = socket.receive(receiveBuffer[receiveBufferUsedLength .. $]);
if(r == 0)
return false;