Fix for windows
[webserver.git] / http.c
diff --git a/http.c b/http.c
index 13223210cba9497a1a5cbd67caf66c58feca1889..dce3cc86d8a81686abd9d483b60d921a2a6ec63e 100644 (file)
--- a/http.c
+++ b/http.c
@@ -63,22 +63,23 @@ typedef struct {
 
 void print_header_values (header_t *header)
 {
-    printf ("allow = '%s'\n", header->allow);
-    printf ("authorization = '%s'\n", header->authorization);
-    printf ("content_encoding = '%s'\n", header->content_encoding);
-    printf ("content_length = '%s'\n", header->content_length);
-    printf ("content_type = '%s'\n", header->content_type);
-    printf ("date = '%s'\n", header->date);
-    printf ("expires = '%s'\n", header->expires);
-    printf ("from = '%s'\n", header->from);
-    printf ("if_modified_since = '%s'\n", header->if_modified_since);
-    printf ("last_modified = '%s'\n", header->last_modified);
-    printf ("location = '%s'\n", header->location);
-    printf ("pragma = '%s'\n", header->pragma);
-    printf ("referer = '%s'\n", header->referer);
-    printf ("server = '%s'\n", header->server);
-    printf ("user_agent = '%s'\n", header->user_agent);
-    printf ("www_authenticate = '%s'\n", header->www_authenticate);
+    printf ("Header values\n");
+    if (header->allow) printf ("allow = '%s'\n", header->allow);
+    if (header->authorization) printf ("authorization = '%s'\n", header->authorization);
+    if (header->content_encoding) printf ("content_encoding = '%s'\n", header->content_encoding);
+    if (header->content_length) printf ("content_length = '%s'\n", header->content_length);
+    if (header->content_type) printf ("content_type = '%s'\n", header->content_type);
+    if (header->date) printf ("date = '%s'\n", header->date);
+    if (header->expires) printf ("expires = '%s'\n", header->expires);
+    if (header->from) printf ("from = '%s'\n", header->from);
+    if (header->if_modified_since) printf ("if_modified_since = '%s'\n", header->if_modified_since);
+    if (header->last_modified) printf ("last_modified = '%s'\n", header->last_modified);
+    if (header->location) printf ("location = '%s'\n", header->location);
+    if (header->pragma) printf ("pragma = '%s'\n", header->pragma);
+    if (header->referer) printf ("referer = '%s'\n", header->referer);
+    if (header->server) printf ("server = '%s'\n", header->server);
+    if (header->user_agent) printf ("user_agent = '%s'\n", header->user_agent);
+    if (header->www_authenticate) printf ("www_authenticate = '%s'\n", header->www_authenticate);
 }
 
 /* find sequence*/
@@ -154,7 +155,7 @@ int add_response_header (char **buffer, char *uri)
     return strlen (*buffer);
 }
 
-int add_entity (char **buffer, unsigned char *entity, int size, char *type, char *encoding)
+int add_entity (char **buffer, char *entity, int size, char *type, char *encoding)
 {
     char tmp[BUFFER_SIZE] = {0};
     int len = strlen (*buffer);
@@ -200,7 +201,7 @@ int error_400 (char **buffer)
     add_response_header (buffer, NULL);
 
     char *response = "<html><head><title>Error 400</title></head><body><p>Bad Request</p></body></html>";
-    return add_entity (buffer, (unsigned char *)response, strlen (response), "text/html", "iso-8859-1");
+    return add_entity (buffer, response, strlen (response), "text/html", "iso-8859-1");
 }
 
 /* error 404 */
@@ -212,7 +213,7 @@ int error_404 (char **buffer, char *uri)
     add_response_header (buffer, uri);
 
     char *response = "<html><head><title>Error 404</title></head><body><p>File not found</p></body></html>";
-    return add_entity (buffer, (unsigned char *)response, strlen (response), "text/html", "iso-8859-1");
+    return add_entity (buffer, response, strlen (response), "text/html", "iso-8859-1");
 }
 
 /* response html */
@@ -223,7 +224,7 @@ int response_html (char **buffer, char *location, char *response)
     add_general_header (buffer);
     add_response_header (buffer, location);
 
-    return add_entity (buffer, (unsigned char *)response, strlen (response), "text/html", "iso-8859-1");
+    return add_entity (buffer, response, strlen (response), "text/html", "iso-8859-1");
 }
 
 /* trim string */
@@ -337,7 +338,7 @@ int processing (char *data, int len, char *root, char **pdata)
     char *buffer = NULL;
     switch (type) {
     case get_e:
-        len = readfile ((unsigned char **)&buffer, filename);
+        len = readfile (&buffer, filename);
         if (len == 0) {
             len = error_404 (pdata, "http://localhost/");
         } else {