mongoose/docs/c-api/mg_http_server.h/mg_send_http_chunk.md
Dmitry Frank 3eb4eb8074 Fix mongoose docs generation
PUBLISHED_FROM=331821dcd1f7dc8a94581cd8a9b51aa00a89fddc
2018-02-03 01:20:48 +02:00

849 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);

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

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

NOTE: do not forget to send an 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