Commit 4848895e358bc4c23927fc315e234ec61bac2b33

Thomas de Grivel 2024-07-30T22:56:42

make test_http OK

diff --git a/http/http_request.c b/http/http_request.c
index eda1eac..dbb8d0e 100644
--- a/http/http_request.c
+++ b/http/http_request.c
@@ -33,23 +33,29 @@ s_http_request * http_request_buf_parse (s_http_request *req, s_buf *buf)
     err_puts("http_request_buf_parse: no method");
     goto restore;
   }
-  err_write_1("http_request_buf_parse: method: ");
-  err_inspect_sym(&tmp.method);
-  err_write_1("\n");
+  if (false) {
+    err_write_1("http_request_buf_parse: method: ");
+    err_inspect_sym(&tmp.method);
+    err_write_1("\n");
+  }
   if (! buf_read_until_1_into_str(buf, " ", &tmp.url)) {
     err_puts("http_request_buf_parse: invalid URL");
     goto restore;
   }
-  err_write_1("http_request_buf_parse: url: ");
-  err_inspect_str(&tmp.url);
-  err_write_1("\n");
+  if (false) {
+    err_write_1("http_request_buf_parse: url: ");
+    err_inspect_str(&tmp.url);
+    err_write_1("\n");
+  }
   if (! buf_read_until_1_into_str(buf, "\r\n", &tmp.protocol)) {
     err_puts("http_request_buf_parse: invalid protocol");
     goto restore;
   }
-  err_write_1("http_request_buf_parse: protocol: ");
-  err_inspect_str(&tmp.protocol);
-  err_write_1("\n");
+  if (false) {
+    err_write_1("http_request_buf_parse: protocol: ");
+    err_inspect_str(&tmp.protocol);
+    err_write_1("\n");
+  }
   tail = &tmp.headers;
   while (1) {
     if (! buf_read_until_1_into_str(buf, "\r\n", &line)) {
diff --git a/http/http_response.c b/http/http_response.c
index ddc5658..7294fb0 100644
--- a/http/http_response.c
+++ b/http/http_response.c
@@ -10,13 +10,13 @@
  * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
  * THIS SOFTWARE.
  */
-#include <libkc3/kc3.h>
-#include "http.h"
 #include <string.h>
+#include <libkc3/kc3.h>
+#include "http_response.h"
 #include "socket.h"
 
-sw http_response_buf_write (s_http_response *response,
-                                           s_buf *buf)
+sw http_response_buf_write (const s_http_response *response,
+                            s_buf *buf)
 {
   sw    content_length = -1;
   s_str content_length_str = {0};
diff --git a/http/http_response.h b/http/http_response.h
index 58aa11e..3cca5a5 100644
--- a/http/http_response.h
+++ b/http/http_response.h
@@ -15,7 +15,7 @@
 
 #include "types.h"
 
-const s_http_response * http_response_buf_write
-  (const s_http_response *response, s_buf *buf);
+sw http_response_buf_write (const s_http_response *response,
+                            s_buf *buf);
 
 #endif /* HTTP_RESPONSE_H */
diff --git a/lib/kc3/0.1/http/response.kc3 b/lib/kc3/0.1/http/response.kc3
index 43c9f31..034ad11 100644
--- a/lib/kc3/0.1/http/response.kc3
+++ b/lib/kc3/0.1/http/response.kc3
@@ -1,7 +1,7 @@
 defmodule HTTP.Response do
 
   defstruct [protocol: "HTTP/1.1",
-             code: 200,
+             code: (U16) 200,
              message: "OK",
              headers: [],
              body: ""]
@@ -12,4 +12,4 @@ defmodule HTTP.Response do
 
   def buf_write = cfn Sw "http_response_buf_write" (HTTP.Response, Buf)
 
-end
\ No newline at end of file
+end