nkiss

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nkiss
Log | Files | Refs

commit d7941965df27f71a00e76e5e278446c7b9a2cdc9
parent f6664293f08fb52b553f58f5ff1e6aa1e45c0da0
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Thu, 18 Feb 2021 12:44:09 -0600

http.c: use loop for `write`

Diffstat:
Mhttp.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/http.c b/http.c @@ -302,9 +302,12 @@ http_request(void) fprintf(stderr, "not writing header because it is truncated"); goto err; } - if ((r = write(fd, buf, r)) == -1) { - fprintf(stderr, "write: %s\n", strerror(errno)); - goto err; + + for (len = r, p = buf; len > 0; p += r, len -= r) { + if ((r = write(fd, p, len)) == -1) { + fprintf(stderr, "write: %s\n", strerror(errno)); + goto err; + } } /* NOTE: HTTP header must fit in the buffer */