mongoose/docs/c-api/http.h/mg_send_http_chunk.md
Alexander Alashkin 9101cd0339 Use lld for ID
PUBLISHED_FROM=1246247fc29eb9a75b986ff7bb2d2350a52c03fc
2016-07-22 16:26:31 +00:00

828 B

title decl_name symbol_kind signature
mg_send_http_chunk() mg_send_http_chunk func void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);

Send buffer buf of size len to the client using chunked HTTP encoding. This function first sends buffer size as hex number + newline, then buffer itself, then newline. For example, mg_send_http_chunk(nc, "foo", 3) whill append 3\r\nfoo\r\n string to the nc->send_mbuf output IO buffer.

NOTE: HTTP header "Transfer-Encoding: chunked" should be sent prior to using this function.

NOTE: do not forget to send empty chunk at the end of the response, to tell the client that everything was sent. Example:

  mg_printf_http_chunk(nc, "%s", "my response!");
  mg_send_http_chunk(nc, "", 0); // Tell the client we're finished