add test_http_client_post_ctlen_large default tip

Fri, 27 Feb 2026 18:05:12 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 27 Feb 2026 18:05:12 +0100
changeset 709
b446c4b12ad4
parent 708
027b16665f13

add test_http_client_post_ctlen_large

src/server/test/httpclient.c file | annotate | diff | comparison | revisions
src/server/test/httpclient.h file | annotate | diff | comparison | revisions
src/server/test/main.c file | annotate | diff | comparison | revisions
--- a/src/server/test/httpclient.c	Thu Feb 26 21:43:20 2026 +0100
+++ b/src/server/test/httpclient.c	Fri Feb 27 18:05:12 2026 +0100
@@ -252,7 +252,7 @@
                 "HTTP/1.1 200 OK\r\n"
                 "Content-length: 21\r\n"
                 "\r\n"
-                "Hello World!---post1\n");
+                "Hello World!---post2\n");
         cxstring *response = calloc(response_str.length, sizeof(cxstring));
         for(int i=0;i<response_str.length;i++) {
             response[i] = cx_strn(response_str.ptr+i, 1);
@@ -263,8 +263,31 @@
         CxBuffer *out = cxBufferCreate(NULL, NULL, 256, CX_BUFFER_AUTO_EXTEND|CX_BUFFER_FREE_CONTENTS);
         
         CX_TEST_CALL_SUBROUTINE(test_httpclient, request_body, TRUE, response, response_str.length, out);
-        CX_TEST_ASSERT(!cx_strcmp(cx_strn(out->space, out->size), "Hello World!---post1\n"));
+        CX_TEST_ASSERT(!cx_strcmp(cx_strn(out->space, out->size), "Hello World!---post2\n"));
         
         cxBufferFree(out);
     }
 }
+
+CX_TEST(test_http_client_post_ctlen_large) {
+    CX_TEST_DO {
+        cxstring response = cx_str(
+                "HTTP/1.1 200 OK\r\n"
+                "Content-length: 21\r\n"
+                "\r\n"
+                "Hello World!---post3\n");
+        
+        size_t ctlen = 1024*64;
+        char *req_body = malloc(ctlen);
+        cxstring request_body = cx_strn(req_body, ctlen);
+        
+        CxBuffer *out = cxBufferCreate(NULL, NULL, 256, CX_BUFFER_AUTO_EXTEND|CX_BUFFER_FREE_CONTENTS);
+        
+        request_body_max_read = 4096;
+        CX_TEST_CALL_SUBROUTINE(test_httpclient, request_body, FALSE, &response, 1, out);
+        CX_TEST_ASSERT(!cx_strcmp(cx_strn(out->space, out->size), "Hello World!---post3\n"));
+        
+        cxBufferFree(out);
+        free(req_body);
+    }
+}
--- a/src/server/test/httpclient.h	Thu Feb 26 21:43:20 2026 +0100
+++ b/src/server/test/httpclient.h	Fri Feb 27 18:05:12 2026 +0100
@@ -43,6 +43,7 @@
 CX_TEST(test_http_client_simple_get_small_blocksize);
 CX_TEST(test_http_client_simple_get_1b_blocksize);
 CX_TEST(test_http_client_post_ctlen);
+CX_TEST(test_http_client_post_ctlen_large);
 CX_TEST(test_http_client_post_chunked);
 
 
--- a/src/server/test/main.c	Thu Feb 26 21:43:20 2026 +0100
+++ b/src/server/test/main.c	Fri Feb 27 18:05:12 2026 +0100
@@ -216,6 +216,7 @@
     cx_test_register(suite, test_http_client_simple_get_1b_blocksize);
     cx_test_register(suite, test_http_client_post_ctlen);
     cx_test_register(suite, test_http_client_post_chunked);
+    cx_test_register(suite, test_http_client_post_ctlen_large);
     
     // plugin tests
 #ifdef ENABLE_POSTGRESQL

mercurial