diff options
author | cflip <cflip@cflip.net> | 2023-05-27 11:50:37 -0600 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2023-05-27 11:50:37 -0600 |
commit | 30458088f0f6acbb9581fecd2aa39d97c13d7373 (patch) | |
tree | 71ee8fc561a3ee3be1e674cdb9db1c3a600080f6 /http.c | |
parent | 7f1d6bbc335288df1e24e7c8f305c32afe6b050a (diff) |
Load and serve files from the filesystem
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -30,8 +30,7 @@ void http_free_request(struct http_request *req) free(req->uri); } -void http_build_response(char **res, enum http_res_code code, const char *msg) +int http_build_response(char *res, enum http_res_code code, const char *msg, size_t msglen) { - *res = malloc(128); - sprintf(*res, "HTTP/1.1 200 OK\r\n\r\n%s\r\n", msg); + return snprintf(res, CFWS_MAX_RESPONSE, "HTTP/1.1 200 OK\r\n\r\n%.*s\r\n", msglen, msg); } |