[vlc-devel] [PATCH 1/2] httpd: Fix answer sending from custom handlers

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Jun 11 12:59:29 CEST 2020


In case of custom handlers, the entire response is crafted by pf_fill.
This will in turn cause 0 bytes of headers to be sent, which is expected
since those headers are contained in the answer, however we will treat
such a case as a dead connection, which prevents the actual answer
including its headers to be sent
---
 src/network/httpd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index e93f3c09c3..0d0ca2ec66 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1609,6 +1609,7 @@ static int httpd_ClientSend(httpd_client_t *cl)
         cl->i_buffer_size = (uint8_t*)p - cl->p_buffer;
     }
 
+    if (cl->i_buffer_size != cl->i_buffer) {
     i_len = httpd_NetSend(cl, &cl->p_buffer[cl->i_buffer],
                            cl->i_buffer_size - cl->i_buffer);
 
@@ -1631,6 +1632,7 @@ static int httpd_ClientSend(httpd_client_t *cl)
     }
 
     cl->i_buffer += i_len;
+    }
 
     if (cl->i_buffer >= cl->i_buffer_size) {
         if (cl->answer.i_body == 0  && cl->answer.i_body_offset > 0) {
-- 
2.20.1



More information about the vlc-devel mailing list