implement HttpClient function create_req_buffer default tip

Thu, 12 Feb 2026 16:02:09 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 12 Feb 2026 16:02:09 +0100
changeset 668
0a7d1e9ca6b8
parent 667
1f0f014c0121

implement HttpClient function create_req_buffer

src/server/proxy/httpclient.c file | annotate | diff | comparison | revisions
src/server/proxy/httpclient.h file | annotate | diff | comparison | revisions
--- a/src/server/proxy/httpclient.c	Thu Feb 12 11:20:43 2026 +0100
+++ b/src/server/proxy/httpclient.c	Thu Feb 12 16:02:09 2026 +0100
@@ -122,7 +122,27 @@
         return 1;
     }
     
+    if(client->method) {
+        cxBufferPutString(&buf, "GET ");
+    } else {
+        cxBufferPutString(&buf, client->method);
+    }
+    cxBufferPutString(&buf, client->uri ? client->uri : "/");
+    cxBufferPutString(&buf, " HTTP/1.1\r\n");
     
+    HeaderArray *hdr = client->request_headers;
+    while(hdr) {
+        for(int i=0;i<hdr->len;i++) {
+            cxBufferPutString(&buf, hdr->headers[i].name);
+            cxBufferPutString(&buf, ": ");
+            cxBufferPutString(&buf, hdr->headers[i].value);
+            cxBufferPutString(&buf, "\r\n");
+        }
+        hdr = hdr->next;
+    }
+    cxBufferPutString(&buf, "\r\n");
+    client->req_buffer = buf.space;
+    client->req_buffer_len = buf.size;
     
     return 0;
 }
--- a/src/server/proxy/httpclient.h	Thu Feb 12 11:20:43 2026 +0100
+++ b/src/server/proxy/httpclient.h	Thu Feb 12 16:02:09 2026 +0100
@@ -44,6 +44,7 @@
 struct HttpClient {
     EventHandler *ev;
     CxMempool *mp;
+    char *method;
     char *uri;
     
     struct sockaddr *addr;

mercurial