diff -r 66bde992ebd0 -r a5f3e1e5e744 src/server/test/io.c --- a/src/server/test/io.c Mon Mar 16 19:44:18 2026 +0100 +++ b/src/server/test/io.c Tue Mar 17 20:49:37 2026 +0100 @@ -675,6 +675,41 @@ } } +CX_TEST(test_io_httpstream_chunked_write_partial_writev) { + Session *sn = testutil_session(); + + TestIOStream *st = testutil_iostream(2048, TRUE); + IOStream *http = httpstream_new(sn->pool, (IOStream*)st); + httpstream_enable_chunked_write(http); + io_set_max_writes(1); + + CX_TEST_DO { + + memset(st->buf->space, 0, st->buf->capacity); + + char *msg = "hello world!"; + size_t msglen = strlen(msg); + + // Test: write complete chunk header, zero data + + st->max_write = 3; + ssize_t w = net_write(http, msg, msglen); + + CX_TEST_ASSERT(w == 0); + + st->max_write = 1000; + w = net_write(http, msg, msglen); + + CX_TEST_ASSERT(w == msglen); + + CX_TEST_ASSERT(!memcmp(st->buf->space, "c\r\nhello world!\r\n", st->buf->size)); + + testutil_destroy_session(sn); + testutil_iostream_destroy(st); + + } +} + CX_TEST(test_io_httpstream_chunked_write_data_2x) { Session *sn = testutil_session();