summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'http.c')
-rw-r--r--http.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/http.c b/http.c
index d6f495d..b6bad8e 100644
--- a/http.c
+++ b/http.c
@@ -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);
}