]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/docs/api/mg_response_header_X.md
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / prometheus-cpp / 3rdparty / civetweb / docs / api / mg_response_header_X.md
1 # Civetweb API Reference
2
3 ### `mg_response_header_start( conn, status );`
4 ### `mg_response_header_add( conn, header, value, value_len );`
5 ### `mg_response_header_add_lines( conn, http1_headers );`
6 ### `mg_response_header_send( conn );`
7
8 ### Parameters
9
10 | Parameter | Type | Description |
11 | :--- | :--- | :--- |
12 |**`conn`**|`struct mg_connection *`|The server is sending a response to this connection|
13 |**`status`**|`int`|HTTP status code to send (100-599)|
14 |**`header`**|`const char *`|HTTP header name|
15 |**`value`**|`const char *`|HTTP header value|
16 |**`value_len`**|`int`|Length of HTTP header value. -1 will use the entire value string.|
17 |**`http1_headers`**|`const char *`|String in format "Key: Value\r\nKey2: Value2"|
18
19 ### Return Value
20
21 | Type | Description |
22 |`int`| An integer indicating success (>=0) or failure (<0). |
23 |`-1`| Error: Invalid parameter (e.g., NULL pointer or value out of range) |
24 |`-2`| Error: Invalid connection type. These functions must only be used in web server request handlers. |
25 |`-3`| Error: Invalid connection status. These functions must be used before `mg_send()` or `mg_printf()` functions. |
26 |`-4`| Error: Too many headers. The total number of header lines is limited to MG_MAX_HEADERS (default: 64). |
27 |`-5`| Error: Out of memory. |
28
29
30 ### Description
31
32 The `mg_response_header_*` family of functions can be used to send HTTP response headers from a web server handler function.
33 Do not use it for HTTP clients or websockets. When using `mg_response_header_*` functions, they must be used to send all HTTP headers - combining `mg_response_header_*` functions and `mg_send_*`/`mg_write`/`mg_printf` to send HTTP headers is not possible.
34 After sending HTTP headers, HTTP body data is still sent using `mg_write`/`mg_printf`.
35
36 All `mg_response_header_*` functions must be used prior to any call to `mg_write`/`mg_printf`, in the following order:
37
38 1) `mg_response_header_start` (once)
39 2) `mg_response_header_add` (0 - 64 times), alternatively `mg_response_header_add_lines`. The preferred function is `mg_response_header_add`. The function `mg_response_header_add_lines` can process HTTP/1.x formatted header lines and is used for compatibility.
40 3) `mg_response_header_send` (once)
41 4) `mg_write` or `mg_printf` (multiple) to send the HTTP body
42
43 Using `mg_response_header_*` functions will allow a request handler to process HTTP/1.x and HTTP/2 requests, in contrast to sending HTTP headers directly using `mg_printf`/`mg_write`.
44
45
46 ### See Also
47
48 * [`mg_send_http_ok();`](mg_send_http_ok.md)
49 * [`mg_send_http_error();`](mg_send_http_error.md)
50 * [`mg_send_http_redirect();`](mg_send_http_redirect.md)
51 * [`mg_write();`](mg_write.md)
52 * [`mg_send_chunk();`](mg_send_chunk.md)
53