aboutsummaryrefslogtreecommitdiff
path: root/src/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.c')
-rw-r--r--src/http.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/http.c b/src/http.c
index 4c93a27..1312d4d 100644
--- a/src/http.c
+++ b/src/http.c
@@ -75,8 +75,8 @@ void send_status(const char *status_line) {
"\r\n",
status_line);
- if (send(current_client_socket, http_response, strlen(http_response), 0) <
- 0) {
+ if (beaker_send_all(current_client_socket, http_response,
+ strlen(http_response)) < 0) {
beaker_log_errno_format("ERROR",
"send_status: Failed to send HTTP status.\n");
}
@@ -91,7 +91,7 @@ void send_response(const char *html) {
}
char http_response_header[BUFFER_SIZE * 2];
- int content_length = strlen(html);
+ size_t content_length = strlen(html);
current_response_status = 200;
current_response_size = content_length;
char cookie_headers[BUFFER_SIZE];
@@ -101,20 +101,20 @@ void send_response(const char *html) {
snprintf(http_response_header, sizeof(http_response_header),
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
- "Content-Length: %d\r\n"
+ "Content-Length: %zu\r\n"
"%s"
"Connection: close\r\n"
"\r\n",
content_length, cookie_headers);
- if (send(current_client_socket, http_response_header,
- strlen(http_response_header), 0) < 0) {
+ if (beaker_send_all(current_client_socket, http_response_header,
+ strlen(http_response_header)) < 0) {
beaker_log_errno_format("ERROR",
"send_response: Failed to send HTTP header.\n");
return;
}
- if (send(current_client_socket, html, content_length, 0) < 0) {
+ if (beaker_send_all(current_client_socket, html, content_length) < 0) {
beaker_log_errno_format("ERROR",
"send_response: Failed to send HTML body.\n");
return;
@@ -146,8 +146,8 @@ void send_redirect(const char *location) {
"\r\n",
location, cookie_headers);
- if (send(current_client_socket, http_response_header,
- strlen(http_response_header), 0) < 0) {
+ if (beaker_send_all(current_client_socket, http_response_header,
+ strlen(http_response_header)) < 0) {
beaker_log_errno_format("ERROR",
"send_redirect: Failed to send redirect header.\n");
return;