aboutsummaryrefslogtreecommitdiff
path: root/doc/man7
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-11-18 00:56:04 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-11-18 01:03:12 +0100
commit65031ca3502e0c27780be847fd97c112546741a9 (patch)
tree31c8ac5bb815baf5e4b63bde3af9076eb30a30ed /doc/man7
parentb71a6174e12b4709acaf8bc151938ba12d2a54f6 (diff)
downloadlibweb-65031ca3502e0c27780be847fd97c112546741a9.tar.gz
Send HTTP headers to payload callback
Even if libweb already parses some common headers, such as Content-Length, some users might find it interesting to inspect which headers were received from a request. Since HTTP/1.1 does not define a limit on the number of maximum headers a client can send, for security reasons a maximum value must be provided by the user. Any extra headers shall be then discarded by libweb. An example application showing this new feature is also provided.
Diffstat (limited to 'doc/man7')
-rw-r--r--doc/man7/libweb_handler.78
-rw-r--r--doc/man7/libweb_http.719
2 files changed, 23 insertions, 4 deletions
diff --git a/doc/man7/libweb_handler.7 b/doc/man7/libweb_handler.7
index 5c910e0..b9fd53f 100644
--- a/doc/man7/libweb_handler.7
+++ b/doc/man7/libweb_handler.7
@@ -1,4 +1,4 @@
-.TH LIBWEB_HANDLER 7 2023-09-15 0.1.0 "libweb Library Reference"
+.TH LIBWEB_HANDLER 7 2023-11-18 0.2.0 "libweb Library Reference"
.SH NAME
libweb_handler \- libweb high-level website configuration
@@ -69,15 +69,17 @@ struct handler_cfg
const char *\fItmpdir\fP;
int (*\fIlength\fP)(unsigned long long len, const struct http_cookie *c, struct http_response *r, void *user);
void *\fIuser\fP;
+ size_t \fImax_headers\fP;
};
.EE
.in
.PP
.IR tmpdir ,
-.I length
-and
+.IR length ,
.I user
+and
+.I max_headers
are passed directly to the
.I struct http_cfg
object used to initialize a
diff --git a/doc/man7/libweb_http.7 b/doc/man7/libweb_http.7
index 329a616..93bb882 100644
--- a/doc/man7/libweb_http.7
+++ b/doc/man7/libweb_http.7
@@ -1,4 +1,4 @@
-.TH LIBWEB_HTTP 7 2023-09-15 0.1.0 "libweb Library Reference"
+.TH LIBWEB_HTTP 7 2023-11-18 0.2.0 "libweb Library Reference"
.SH NAME
libweb_http \- libweb HTTP connection handling and utilities
@@ -84,6 +84,7 @@ struct http_cfg
int (*\fIlength\fP)(unsigned long long \fIlen\fP, const struct http_cookie *\fIc\fP, struct http_response *\fIr\fP, void *\fIuser\fP);
const char *\fItmpdir\fP;
void *\fIuser\fP;
+ size_t \fImax_headers\fP;
};
.EE
.in
@@ -195,6 +196,15 @@ other function pointers defined by
.I user
can be a null pointer.
+.I max_headers
+refers to the maximum number of header fields that shall be passed to the
+.IR "struct http_payload"
+object passed to the function pointed to by
+.IR payload .
+Any extra headers sent by the client outside this maximum value shall be
+silently ignored by
+.IR libweb .
+
.SS HTTP payload
When a client submits a request to the server,
@@ -224,6 +234,8 @@ struct http_payload
const struct http_arg *\fIargs\fP;
size_t \fIn_args\fP;
+ const struct http_header *\fIheaders\fP;
+ size_t \fIn_headers\fP;
};
.EE
.in
@@ -260,6 +272,11 @@ defines a list of key-value pairs containing URL parameters. Its length
is defined by
.IR n_args .
+.I headers
+defines a list of key-value pairs containing header fields. Its length
+is defined by
+.IR n_headers .
+
.SS HTTP POST payload
As opposed to payload-less HTTP/1.1 operations, such as