For chunked encoding on switch to STATE_RESPONSE_CHUNKED_TRAILER when
authorclaudio <claudio@openbsd.org>
Wed, 3 Nov 2021 13:29:28 +0000 (13:29 +0000)
committerclaudio <claudio@openbsd.org>
Wed, 3 Nov 2021 13:29:28 +0000 (13:29 +0000)
the full chunk was fetched. If the chunk size is bigger than
HTTP_BUF_SIZE iosz will be not zero and STATE_RESPONSE_DATA should
be used to fetch another buffer full of data.
OK beck@

usr.sbin/rpki-client/http.c

index 1cd8102..25d951a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: http.c,v 1.46 2021/10/29 08:51:20 claudio Exp $  */
+/*     $OpenBSD: http.c,v 1.47 2021/11/03 13:29:28 claudio Exp $  */
 /*
  * Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -1679,7 +1679,7 @@ data_write(struct http_connection *conn)
 
        /* all data written, switch back to read */
        if (conn->bufpos == 0 || conn->iosz == 0) {
-               if (conn->chunked)
+               if (conn->chunked && conn->iosz == 0)
                        conn->state = STATE_RESPONSE_CHUNKED_TRAILER;
                else
                        conn->state = STATE_RESPONSE_DATA;