Browse Source

fix: debug info

RegMs If 4 năm trước cách đây
mục cha
commit
21695a9837
3 tập tin đã thay đổi với 4 bổ sung6 xóa
  1. BIN
      lab8/server
  2. 4 4
      lab8/server.c
  3. 0 2
      lab8/sockio.c

BIN
lab8/server


+ 4 - 4
lab8/server.c

@@ -113,6 +113,8 @@ void send_header(int clnt_sock, struct buffer *send_buf, struct buffer *line_buf
                                            "\r\n",
                             protocol, status, content_type, content_length);
     sputline(clnt_sock, send_buf, line_buf);
+
+    printf("\tresponse: protocol = %s, status = %s, content type = %s, content length = %lu.\n", protocol, status, content_type, content_length);
 }
 
 // handle connection
@@ -161,10 +163,8 @@ void *conn(void *id)
             *p = '\0';
         }
 
-        printf("Client %hu: method = %s, url = %s, protocol = %s.\n", clnt_id, method, url, protocol);
-
         // request headers
-        int content_length = 0;
+        size_t content_length = 0;
 
         for (;;)
         {
@@ -187,7 +187,7 @@ void *conn(void *id)
             break;
         }
 
-        printf("Client %hu: content length = %d.\n", clnt_id, content_length);
+        printf("Client %hu request: method = %s, url = %s, protocol = %s, content length = %lu.\n", clnt_id, method, url, protocol, content_length);
 
         // request body
         char *request_body = (char *)malloc(content_length + 1);

+ 0 - 2
lab8/sockio.c

@@ -1,7 +1,5 @@
 #include "sockio.h"
 
-#include <stdio.h>
-
 // get char from client socket
 int sgetc(int clnt_sock, struct buffer *recv_buf)
 {