int ht_sendbuf(struct HttpSocketInfo *si, char *buf, int length);
This routine is called whenever data needs to be sent by the HTTP Server. Depending on flags on structure HttpSocketInfo, it calls
sys_send() for non-secure HTTP connection and calls
ssl_send() for secure HTTP connection.
If data chunking is being used in reply to a HTTP request, then
http_sendbuf() does the appropriate formatting. That is it sends the length fields, followed by CRLF, followed by data, followed by CRLF. If buff is
NULL and length is 0, then it means that all data has been sent and then the last-chunk needs to be sent (0 followed by CRLF CRL).
When applications like CGI, SSI, Server Push, need to send data, they can call
ht_sendbuf() with the first argument being "
&hp->si". These application functions are called with "struct httpd * hp" and the address of "si" field needs to be passed to
Returns bytes after writing from secure or non-secure HTTP connection.
The extra bytes sent for chunking are not reported in the return value. That is, the maximum return value is equal to the received length.