Noticed by accident. The chunked encoding only works for chunks smaller than 32k (the HTTP internal read buffer). For chunks bigger than 32k the state machine jumps too early (after the first write of 32k) into the STATE_RESPONSE_CHUNKED_TRAILER state and so everything gets confused.
Fix is simple. Check in data_write() that for chunked encoding iosz is null before switching to STATE_RESPONSE_CHUNKED_TRAILER. -- :wq Claudio Index: http.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v retrieving revision 1.46 diff -u -p -r1.46 http.c --- http.c 29 Oct 2021 08:51:20 -0000 1.46 +++ http.c 3 Nov 2021 11:39:16 -0000 @@ -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;