commit f39ef3e41b3829f8d62c28e218bf9f7bb3743f1d from: Omar Polo date: Thu Sep 07 17:26:38 2023 UTC amused-web: http_reply: use http_* instead of bufio_compose_* commit - 35cca6c55330a7856d646faee8f4677796fe0b54 commit + f39ef3e41b3829f8d62c28e218bf9f7bb3743f1d blob - d4bb9f21482cb2d263537bbf911346ba36f62299 blob + 75b8cd43bfd889cd1f33d56beb1869ad32225af7 --- web/http.c +++ web/http.c @@ -248,27 +248,27 @@ http_reply(struct client *clt, int code, const char *r if (clt->req.version == HTTP_1_0) version = "HTTP/1.0"; - if (bufio_compose_fmt(&clt->bio, "%s %d %s\r\n" + if (http_fmt(clt, "%s %d %s\r\n" "Connection: close\r\n" "Cache-Control: no-store\r\n", version, code, reason) == -1) goto err; if (ctype != NULL && - bufio_compose_fmt(&clt->bio, "Content-Type: %s\r\n", ctype) == -1) + http_fmt(clt, "Content-Type: %s\r\n", ctype) == -1) goto err; if (location != NULL && - bufio_compose_fmt(&clt->bio, "Location: %s\r\n", location) == -1) + http_fmt(clt, "Location: %s\r\n", location) == -1) goto err; - if (clt->chunked && bufio_compose_str(&clt->bio, - "Transfer-Encoding: chunked\r\n") == -1) + if (clt->chunked && + http_writes(clt, "Transfer-Encoding: chunked\r\n") == -1) goto err; if (code == 101) { - if (bufio_compose_fmt(&clt->bio, "Upgrade: websocket\r\n" + if (http_fmt(clt, "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Sec-WebSocket-Accept: %s\r\n", b32) == -1) goto err; } - if (bufio_compose(&clt->bio, "\r\n", 2) == -1) + if (http_write(clt, "\r\n", 2) == -1) goto err; bufio_set_chunked(&clt->bio, clt->chunked);