From 8d48785caf80ee26c02995dcca482626410099a3 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sat, 15 Jul 2023 21:41:25 +0000 Subject: [PATCH] Fix extra LF between chunks --- http-response-bodies.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/http-response-bodies.c b/http-response-bodies.c index 898d040..0fbb4ce 100644 --- a/http-response-bodies.c +++ b/http-response-bodies.c @@ -296,7 +296,9 @@ checkstate: DEBUG_PRINTF("Full body\n"); DEBUG_PRINTF("Copying %zu bytes to stdout\n", length - bytes_read); fwrite(bufp, 1, length - bytes_read, stdout); - fprintf(stdout, "\n"); + if (state == STATE_BODY) { + fprintf(stdout, "\n"); + } if (state == STATE_CHUNK_CONTENTS && *(bufp + length - bytes_read) == '\r') { // Stupid hack to enforce the CRLF ++length; @@ -363,6 +365,7 @@ checkstate: fprintf(stderr, "Error: end of HTTP body not found\n"); return 1; } + fprintf(stdout, "\n"); n -= 3; bufp += 3; state = STATE_HEADERS;