Commit 64736703709856008ebc6db3b8bda19346330f99

Thomas de Grivel 2024-08-12T12:18:17

httpd working, with corrected Content-Length

diff --git a/.ikc3_history b/.ikc3_history
index 39f7287..fa20a8e 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,10 +1,3 @@
-Struct.offset(%HTTP.Response{}, :code)
-Struct.offset(%HTTP.Response{}, :message)
-Struct.offset(%HTTP.Response{}, :headers)
-Struct.offset(%HTTP.Response{}, :body)
-Struct.offset(%HTTP.Response{}, :message)
-Struct.offset(%HTTP.Response{}, :protocol)
-Struct.offset(%HTTP.Response{}, :code)
 Struct.offset(%HTTP.Response{}, :message)
 Struct.offset(%HTTP.Response{}, :headers)
 Struct.offset(%HTTP.Response{}, :body)
@@ -97,4 +90,11 @@ Fact.subject(%Fact{})
 quote quote quote %Socket.Buf{}
 quote quote quote %Socket.Buf{sockfd: (S32) 1}
 "#{%Socket.Buf{}}"
+%HTTP.Request{}
+"#{%HTTP.Request{}}"
+"#{%HTTP.Request{headers: [{"Content-Type", "text/html"}]}}"
+req = %HTTP.Request{headers: [{"Content-Type", "text/html"}]}
+#{req}
+"#{req}"
+req = %HTTP.Request{headers: ["Content-Type" => "text/html"]}
 
diff --git a/http/http_response.c b/http/http_response.c
index 13262b8..5ff504a 100644
--- a/http/http_response.c
+++ b/http/http_response.c
@@ -116,14 +116,14 @@ sw http_response_buf_write (const s_http_response *response,
     result += r;
     l = list_next(l);
   }
-  if (content_length < 0 && send_body) {
+  if (content_length < 0) {
     if ((r = buf_write_str(buf, &content_length_str)) < 0)
       return r;
     result += r;
     if ((r = buf_write_1(buf, ": ")) < 0)
       return r;
     result += r;
-    if ((r = buf_inspect_sw_decimal(buf, &content_length)) < 0)
+    if ((r = buf_inspect_uw_decimal(buf, &response->body.size)) < 0)
       return r;
     result += r;
     if ((r = buf_write_1(buf, "\r\n")) < 0)