Improve writing of data

This commit is contained in:
Kamil Trzcinski
2022-04-06 17:52:13 +02:00
parent 6f8f66da59
commit 4a7a42bab2
6 changed files with 139 additions and 82 deletions

View File

@ -12,16 +12,29 @@ void http_index(http_worker_t *worker, FILE *stream)
fflush(stream);
}
void http_404_header(http_worker_t *worker, FILE *stream)
void http_custom_header(FILE *stream, const char *status)
{
fprintf(stream, "HTTP/1.1 %s\r\n", status);
fprintf(stream, "Content-Type: text/plain\r\n");
fprintf(stream, "\r\n");
}
void http_404_header(FILE *stream)
{
http_custom_header(stream, "404 Not Found");
fprintf(stream, "HTTP/1.1 404 Not Found\r\n");
fprintf(stream, "Content-Type: text/plain\r\n");
fprintf(stream, "\r\n");
}
void http_500_header(FILE *stream)
{
http_custom_header(stream, "500 Server Error");
}
void http_404(http_worker_t *worker, FILE *stream)
{
http_404_header(worker, stream);
http_404_header(stream);
fprintf(stream, "Nothing here?\r\n");
}