src/server/test/io.c

changeset 734
a5f3e1e5e744
parent 702
ee80191310ca
equal deleted inserted replaced
733:66bde992ebd0 734:a5f3e1e5e744
673 testutil_iostream_destroy(st); 673 testutil_iostream_destroy(st);
674 674
675 } 675 }
676 } 676 }
677 677
678 CX_TEST(test_io_httpstream_chunked_write_partial_writev) {
679 Session *sn = testutil_session();
680
681 TestIOStream *st = testutil_iostream(2048, TRUE);
682 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);
683 httpstream_enable_chunked_write(http);
684 io_set_max_writes(1);
685
686 CX_TEST_DO {
687
688 memset(st->buf->space, 0, st->buf->capacity);
689
690 char *msg = "hello world!";
691 size_t msglen = strlen(msg);
692
693 // Test: write complete chunk header, zero data
694
695 st->max_write = 3;
696 ssize_t w = net_write(http, msg, msglen);
697
698 CX_TEST_ASSERT(w == 0);
699
700 st->max_write = 1000;
701 w = net_write(http, msg, msglen);
702
703 CX_TEST_ASSERT(w == msglen);
704
705 CX_TEST_ASSERT(!memcmp(st->buf->space, "c\r\nhello world!\r\n", st->buf->size));
706
707 testutil_destroy_session(sn);
708 testutil_iostream_destroy(st);
709
710 }
711 }
712
678 CX_TEST(test_io_httpstream_chunked_write_data_2x) { 713 CX_TEST(test_io_httpstream_chunked_write_data_2x) {
679 Session *sn = testutil_session(); 714 Session *sn = testutil_session();
680 715
681 TestIOStream *st = testutil_iostream(2048, TRUE); 716 TestIOStream *st = testutil_iostream(2048, TRUE);
682 IOStream *http = httpstream_new(sn->pool, (IOStream*)st); 717 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);

mercurial