Styles and some error handling
@@ -296,9 +296,9 @@ int http_set_cookie(http_s *h, http_cookie_args_s cookie) {
set_header_add(h->private_data.out_headers, HTTP_HEADER_SET_COOKIE, c);
return 0;
}
-
#define http_set_cookie(http__req__, ...) \
http_set_cookie((http__req__), (http_cookie_args_s){__VA_ARGS__})
+
/**
* Sends the response headers and body.
*
@@ -307,6 +307,10 @@ int http_set_cookie(http_s *h, http_cookie_args_s cookie) {
* AFTER THIS FUNCTION IS CALLED, THE `http_s` OBJECT IS NO LONGER VALID.
*/
int http_send_body(http_s *r, void *data, uintptr_t length) {
+ if (!length || !data) {
+ http_finish(r);
+ return 0;
+ }
if (!r || !r->private_data.out_headers)
return -1;
add_content_length(r, length);
