send(sock, "HTTP/1.1 200 OK\r\n", 17, 0);
send(sock, "Connection: close\r\n", 19, 0);
+ send(sock, "Server: ", 8, 0);
+ send(sock, "LibW3-HTTPd (LibW3/", 19, 0);
+ send(sock, LIBW3_VERSION, strlen(LIBW3_VERSION), 0);
+ send(sock, ")", 1, 0);
+ send(sock, "\r\n", 2, 0);
send(sock, "Content-Type: text/html\r\n", 25, 0);
char* length = malloc(1025);
sprintf(length, "%d", strlen(html));
}else{
send(sock, "HTTP/1.1 308 Permanent Redirect\r\n", 33, 0);
send(sock, "Connection: close\r\n", 19, 0);
+ send(sock, "Server: ", 8, 0);
+ send(sock, "LibW3-HTTPd (LibW3/", 19, 0);
+ send(sock, LIBW3_VERSION, strlen(LIBW3_VERSION), 0);
+ send(sock, ")", 1, 0);
+ send(sock, "\r\n", 2, 0);
send(sock, "Location: ", 10, 0);
send(sock, path, strlen(path), 0);
send(sock, "/", 1, 0);
send(sock, length, strlen(length), 0);
free(length);
send(sock, "\r\n", 2, 0);
+ send(sock, "Server: ", 8, 0);
+ send(sock, "LibW3-HTTPd (LibW3/", 19, 0);
+ send(sock, LIBW3_VERSION, strlen(LIBW3_VERSION), 0);
+ send(sock, ")", 1, 0);
+ send(sock, "\r\n", 2, 0);
send(sock, "\r\n", 2, 0);
FILE* f = fopen(realpath, "r");
char* buf = malloc(BUFFER_SIZE);
"</html>"
);
badreq_header = malloc(2048);
- sprintf(badreq_header, "HTTP/1.1 400 Bad Request\r\nContent-Type: text/html\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", strlen(badreq));
+ sprintf(badreq_header, "HTTP/1.1 400 Bad Request\r\nContent-Type: text/html\r\nContent-Length: %d\r\nServer: LibW3-HTTPd (LibW3/" LIBW3_VERSION ")\r\nConnection: close\r\n\r\n", strlen(badreq));
notfound = __W3_Strdup(
"</html>"
);
notfound_header = malloc(2048);
- sprintf(notfound_header, "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: %d\r\nConnection: close\r\n\r\n", strlen(notfound));
+ sprintf(notfound_header, "HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\nContent-Length: %d\r\nServer: LibW3-HTTPd (LibW3/" LIBW3_VERSION ")\r\nConnection: close\r\n\r\n", strlen(notfound));
FILE* f = fopen(configfile, "r");
if(f != NULL){