mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix: resize buffer correctly when checking for http header line (#894)
* fix: resize buffer correctly when checking for http header line Fixes #779 Signed-off-by: Roman Gershman <roman@dragonflydb.io> * fix(tests): Add big command test Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io> --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io> Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io> Co-authored-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
parent
edbd43a3b3
commit
ac280529cb
2 changed files with 16 additions and 0 deletions
|
@ -502,6 +502,8 @@ io::Result<bool> Connection::CheckForHttpProto(FiberSocketBase* peer) {
|
|||
size_t last_len = 0;
|
||||
do {
|
||||
auto buf = io_buf_.AppendBuffer();
|
||||
DCHECK(!buf.empty());
|
||||
|
||||
::io::Result<size_t> recv_sz = peer->Recv(buf);
|
||||
if (!recv_sz) {
|
||||
return make_unexpected(recv_sz.error());
|
||||
|
@ -518,6 +520,7 @@ io::Result<bool> Connection::CheckForHttpProto(FiberSocketBase* peer) {
|
|||
return MatchHttp11Line(ib);
|
||||
}
|
||||
last_len = io_buf_.InputLen();
|
||||
io_buf_.EnsureCapacity(io_buf_.Capacity());
|
||||
} while (last_len < 1024);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -276,3 +276,16 @@ async def test_multi_pubsub(async_client):
|
|||
state, message = await run_multi_pubsub(async_client, messages, "my-channel")
|
||||
|
||||
assert state, message
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_big_command(df_server, size=8 * 1024):
|
||||
reader, writer = await asyncio.open_connection('127.0.0.1', df_server.port)
|
||||
|
||||
writer.write(f"SET a {'v'*size}\n".encode())
|
||||
await writer.drain()
|
||||
|
||||
assert 'OK' in (await reader.readline()).decode()
|
||||
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue