aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/http_static/http_static_test.c
diff options
context:
space:
mode:
authorSemir Sionek <ssionek@cisco.com>2025-01-17 10:06:23 -0500
committerFlorin Coras <florin.coras@gmail.com>2025-01-23 18:30:28 +0000
commit5e94895dfd7d597a88965e6b5c1d2a3bc6ffe67e (patch)
tree488c998e057296d7fecefb11c1756289e58f34d5 /src/plugins/http_static/http_static_test.c
parent7267149267fae4bb814af441fabb42767c1a720d (diff)
http_static: introduce max-body-size parameter
Introduce the max-body-size parameter to put a limit on how big of a POST request can the static server take (and how big of a memory allocation that causes). Type: improvement Change-Id: I93cdeaf38dabe2850665e92bedbaa0545c375214 Signed-off-by: Semir Sionek <ssionek@cisco.com>
Diffstat (limited to 'src/plugins/http_static/http_static_test.c')
-rw-r--r--src/plugins/http_static/http_static_test.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/plugins/http_static/http_static_test.c b/src/plugins/http_static/http_static_test.c
index edb016f9e05..56487893220 100644
--- a/src/plugins/http_static/http_static_test.c
+++ b/src/plugins/http_static/http_static_test.c
@@ -214,6 +214,104 @@ api_http_static_enable_v3 (vat_main_t *vam)
mp->private_segment_size = ntohl (private_segment_size);
mp->max_age = ntohl (max_age);
mp->keepalive_timeout = ntohl (keepalive_timeout);
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
+api_http_static_enable_v4 (vat_main_t *vam)
+{
+ unformat_input_t *line_input = vam->input;
+ vl_api_http_static_enable_v4_t *mp;
+ u64 tmp;
+ u8 *www_root = 0;
+ u8 *uri = 0;
+ u32 prealloc_fifos = 0;
+ u32 private_segment_size = 0;
+ u32 fifo_size = 8 << 10;
+ u32 cache_size_limit = 1 << 20;
+ u32 max_age = HSS_DEFAULT_MAX_AGE;
+ u32 keepalive_timeout = HSS_DEFAULT_KEEPALIVE_TIMEOUT;
+ u64 max_body_size = HSS_DEFAULT_MAX_BODY_SIZE;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "www-root %s", &www_root))
+ ;
+ else if (unformat (line_input, "prealloc-fifos %d", &prealloc_fifos))
+ ;
+ else if (unformat (line_input, "private-segment-size %U",
+ unformat_memory_size, &tmp))
+ {
+ if (tmp >= 0x100000000ULL)
+ {
+ errmsg ("private segment size %llu, too large", tmp);
+ return -99;
+ }
+ private_segment_size = (u32) tmp;
+ }
+ else if (unformat (line_input, "fifo-size %U", unformat_memory_size,
+ &tmp))
+ {
+ if (tmp >= 0x100000000ULL)
+ {
+ errmsg ("fifo-size %llu, too large", tmp);
+ return -99;
+ }
+ fifo_size = (u32) tmp;
+ }
+ else if (unformat (line_input, "cache-size %U", unformat_memory_size,
+ &tmp))
+ {
+ if (tmp < (128ULL << 10))
+ {
+ errmsg ("cache-size must be at least 128kb");
+ return -99;
+ }
+ cache_size_limit = (u32) tmp;
+ }
+ else if (unformat (line_input, "max-age %d", &max_age))
+ ;
+ else if (unformat (line_input, "keepalive-timeout %d",
+ &keepalive_timeout))
+ ;
+ else if (unformat (line_input, "uri %s", &uri))
+ ;
+ else if (unformat (line_input, "max-body-size %llu", &max_body_size))
+ ;
+ else
+ {
+ errmsg ("unknown input `%U'", format_unformat_error, line_input);
+ return -99;
+ }
+ }
+
+ if (www_root == 0)
+ {
+ errmsg ("Must specify www-root");
+ return -99;
+ }
+
+ if (uri == 0)
+ uri = format (0, "tcp://0.0.0.0/80%c", 0);
+
+ /* Construct the API message */
+ M (HTTP_STATIC_ENABLE_V4, mp);
+ strncpy_s ((char *) mp->www_root, 256, (const char *) www_root, 256);
+ strncpy_s ((char *) mp->uri, 256, (const char *) uri, 256);
+ mp->fifo_size = ntohl (fifo_size);
+ mp->cache_size_limit = ntohl (cache_size_limit);
+ mp->prealloc_fifos = ntohl (prealloc_fifos);
+ mp->private_segment_size = ntohl (private_segment_size);
+ mp->max_age = ntohl (max_age);
+ mp->keepalive_timeout = ntohl (keepalive_timeout);
+ mp->max_body_size = ntohl (max_body_size);
/* send it... */
S (mp);