mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-08 21:46:54 +08:00
23122b327c
It would be probably good idea to also remove tools/docgen.py and asciidoc.mk, but asciidoc.mk is still mentioned under `cloud/doc`, which may contain some useful info which we'll need at least to review before removing. PUBLISHED_FROM=faf454d4c52a2f07ea8ac084cf0bd11a0c9c9b3b
26 lines
828 B
Markdown
26 lines
828 B
Markdown
---
|
|
title: "mg_send_http_chunk()"
|
|
decl_name: "mg_send_http_chunk"
|
|
symbol_kind: "func"
|
|
signature: |
|
|
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
|
|
```
|
|
|