2 * Copyright (c) 2017-2022 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <http_static/http_static.h>
18 #include <sys/types.h>
22 /** @file static_server.c
23 * Static http server, sufficient to serve .html / .css / .js content.
25 /*? %%clicmd:group_label Static HTTP Server %% ?*/
27 #define HSS_FIFO_THRESH (16 << 10)
31 static hss_session_t *
32 hss_session_alloc (u32 thread_index)
34 hss_main_t *hsm = &hss_main;
37 pool_get_zero (hsm->sessions[thread_index], hs);
38 hs->session_index = hs - hsm->sessions[thread_index];
39 hs->thread_index = thread_index;
40 hs->cache_pool_index = ~0;
44 __clib_export hss_session_t *
45 hss_session_get (u32 thread_index, u32 hs_index)
47 hss_main_t *hsm = &hss_main;
48 if (pool_is_free_index (hsm->sessions[thread_index], hs_index))
50 return pool_elt_at_index (hsm->sessions[thread_index], hs_index);
54 hss_session_free (hss_session_t *hs)
56 hss_main_t *hsm = &hss_main;
58 pool_put (hsm->sessions[hs->thread_index], hs);
62 u32 save_thread_index;
63 save_thread_index = hs->thread_index;
64 /* Poison the entry, preserve timer state and thread index */
65 memset (hs, 0xfa, sizeof (*hs));
66 hs->thread_index = save_thread_index;
70 /** \brief Disconnect a session
73 hss_session_disconnect_transport (hss_session_t *hs)
75 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
76 a->handle = hs->vpp_session_handle;
77 a->app_index = hss_main.app_index;
78 vnet_disconnect_session (a);
82 start_send_data (hss_session_t *hs, http_status_code_t status)
88 ts = session_get (hs->vpp_session_index, hs->thread_index);
90 msg.type = HTTP_MSG_REPLY;
92 msg.content_type = hs->content_type;
93 msg.data.len = hs->data_len;
95 if (hs->data_len > hss_main.use_ptr_thresh)
97 msg.data.type = HTTP_MSG_DATA_PTR;
98 rv = svm_fifo_enqueue (ts->tx_fifo, sizeof (msg), (u8 *) &msg);
99 ASSERT (rv == sizeof (msg));
101 uword data = pointer_to_uword (hs->data);
102 rv = svm_fifo_enqueue (ts->tx_fifo, sizeof (data), (u8 *) &data);
103 ASSERT (rv == sizeof (sizeof (data)));
108 msg.data.type = HTTP_MSG_DATA_INLINE;
110 rv = svm_fifo_enqueue (ts->tx_fifo, sizeof (msg), (u8 *) &msg);
111 ASSERT (rv == sizeof (msg));
116 rv = svm_fifo_enqueue (ts->tx_fifo, hs->data_len, hs->data);
118 if (rv != hs->data_len)
120 hs->data_offset = rv;
121 svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
126 if (svm_fifo_set_event (ts->tx_fifo))
127 session_send_io_evt_to_thread (ts->tx_fifo, SESSION_IO_EVT_TX);
131 hss_session_send_data (hss_url_handler_args_t *args)
135 hs = hss_session_get (args->sh.thread_index, args->sh.session_index);
139 if (hs->data && hs->free_data)
142 hs->data = args->data;
143 hs->data_len = args->data_len;
144 hs->free_data = args->free_vec_data;
145 start_send_data (hs, args->sc);
149 * path_has_known_suffix()
150 * Returns 1 if the request ends with a known suffix, like .htm or .ico
151 * Used to avoid looking for "/favicon.ico/index.html" or similar.
155 path_has_known_suffix (u8 *request)
160 if (vec_len (request) == 0)
165 ext = request + vec_len (request) - 1;
167 while (ext > request && ext[0] != '.')
173 p = hash_get_mem (hss_main.mime_type_indices_by_file_extensions, ext);
181 * content_type_from_request
182 * Returns the index of the request's suffix in the
183 * http-layer http_content_type_str[] array.
186 static http_content_type_t
187 content_type_from_request (u8 *request)
191 /* default to text/html */
192 http_content_type_t rv = HTTP_CONTENT_TEXT_HTML;
194 ASSERT (vec_len (request) > 0);
196 ext = request + vec_len (request) - 1;
198 while (ext > request && ext[0] != '.')
204 p = hash_get_mem (hss_main.mime_type_indices_by_file_extensions, ext);
214 try_url_handler (hss_main_t *hsm, hss_session_t *hs, http_req_method_t rt,
217 http_status_code_t sc = HTTP_STATUS_OK;
218 hss_url_handler_args_t args = {};
219 uword *p, *url_table;
220 http_content_type_t type;
223 if (!hsm->enable_url_handlers || !request)
226 /* zero-length? try "index.html" */
227 if (vec_len (request) == 0)
229 request = format (request, "index.html");
232 type = content_type_from_request (request);
234 /* Look for built-in GET / POST handlers */
236 (rt == HTTP_REQ_GET) ? hsm->get_url_handlers : hsm->post_url_handlers;
238 p = hash_get_mem (url_table, request);
244 hs->cache_pool_index = ~0;
246 if (hsm->debug_level > 0)
247 clib_warning ("%s '%s'", (rt == HTTP_REQ_GET) ? "GET" : "POST", request);
250 args.request = request;
251 args.sh.thread_index = hs->thread_index;
252 args.sh.session_index = hs->session_index;
254 rv = ((hss_url_handler_fn) p[0]) (&args);
256 /* Wait for data from handler */
257 if (rv == HSS_URL_HANDLER_ASYNC)
260 if (rv == HSS_URL_HANDLER_ERROR)
262 clib_warning ("builtin handler %llx hit on %s '%s' but failed!", p[0],
263 (rt == HTTP_REQ_GET) ? "GET" : "POST", request);
264 sc = HTTP_STATUS_NOT_FOUND;
267 hs->data = args.data;
268 hs->data_len = args.data_len;
269 hs->free_data = args.free_vec_data;
270 hs->content_type = type;
272 start_send_data (hs, sc);
275 hss_session_disconnect_transport (hs);
281 file_path_is_valid (u8 *path)
283 struct stat _sb, *sb = &_sb;
285 if (stat ((char *) path, sb) < 0 /* can't stat the file */
286 || (sb->st_mode & S_IFMT) != S_IFREG /* not a regular file */)
293 try_index_file (hss_main_t *hsm, hss_session_t *hs, u8 *path)
295 u8 *port_str = 0, *redirect;
296 transport_endpoint_t endpt;
297 transport_proto_t proto;
303 /* Remove the trailing space */
304 vec_dec_len (path, 1);
305 plen = vec_len (path);
307 /* Append "index.html" */
308 if (path[plen - 1] != '/')
309 path = format (path, "/index.html%c", 0);
311 path = format (path, "index.html%c", 0);
313 if (hsm->debug_level > 0)
314 clib_warning ("trying to find index: %s", path);
316 if (!file_path_is_valid (path))
317 return HTTP_STATUS_NOT_FOUND;
320 * We found an index.html file, build a redirect
322 vec_delete (path, vec_len (hsm->www_root) - 1, 0);
324 ts = session_get (hs->vpp_session_index, hs->thread_index);
325 session_get_endpoint (ts, &endpt, 1 /* is_local */);
327 local_port = clib_net_to_host_u16 (endpt.port);
328 proto = session_type_transport_proto (ts->session_type);
330 if ((proto == TRANSPORT_PROTO_TCP && local_port != 80) ||
331 (proto == TRANSPORT_PROTO_TLS && local_port != 443))
334 port_str = format (0, ":%u", (u32) local_port);
339 "Location: http%s://%U%s%s\r\n\r\n",
340 proto == TRANSPORT_PROTO_TLS ? "s" : "", format_ip46_address,
341 &endpt.ip, endpt.is_ip4, print_port ? port_str : (u8 *) "", path);
343 if (hsm->debug_level > 0)
344 clib_warning ("redirect: %s", redirect);
349 hs->data_len = vec_len (redirect);
352 return HTTP_STATUS_MOVED;
356 try_file_handler (hss_main_t *hsm, hss_session_t *hs, http_req_method_t rt,
359 http_status_code_t sc = HTTP_STATUS_OK;
362 http_content_type_t type;
364 /* Feature not enabled */
368 type = content_type_from_request (request);
371 * Construct the file to open
372 * Browsers are capable of sporadically including a leading '/'
375 path = format (0, "%s%c", hsm->www_root, 0);
376 else if (request[0] == '/')
377 path = format (0, "%s%s%c", hsm->www_root, request, 0);
379 path = format (0, "%s/%s%c", hsm->www_root, request, 0);
381 if (hsm->debug_level > 0)
382 clib_warning ("%s '%s'", (rt == HTTP_REQ_GET) ? "GET" : "POST", path);
384 if (hs->data && hs->free_data)
390 hss_cache_lookup_and_attach (&hsm->cache, path, &hs->data, &hs->data_len);
393 if (!file_path_is_valid (path))
396 * Generate error 404 right now if we can't find a path with
397 * a known file extension. It's silly to look for
398 * "favicon.ico/index.html" if you can't find
399 * "favicon.ico"; realistic example which used to happen.
401 if (path_has_known_suffix (path))
403 sc = HTTP_STATUS_NOT_FOUND;
406 sc = try_index_file (hsm, hs, path);
410 hss_cache_add_and_attach (&hsm->cache, path, &hs->data, &hs->data_len);
413 sc = HTTP_STATUS_INTERNAL_ERROR;
419 hs->cache_pool_index = ce_index;
423 hs->content_type = type;
424 start_send_data (hs, sc);
426 hss_session_disconnect_transport (hs);
432 handle_request (hss_session_t *hs, http_req_method_t rt, u8 *request)
434 hss_main_t *hsm = &hss_main;
436 if (!try_url_handler (hsm, hs, rt, request))
439 if (!try_file_handler (hsm, hs, rt, request))
442 /* Handler did not find anything return 404 */
443 start_send_data (hs, HTTP_STATUS_NOT_FOUND);
444 hss_session_disconnect_transport (hs);
450 hss_ts_rx_callback (session_t *ts)
457 hs = hss_session_get (ts->thread_index, ts->opaque);
459 /* Read the http message header */
460 rv = svm_fifo_dequeue (ts->rx_fifo, sizeof (msg), (u8 *) &msg);
461 ASSERT (rv == sizeof (msg));
463 if (msg.type != HTTP_MSG_REQUEST ||
464 (msg.method_type != HTTP_REQ_GET && msg.method_type != HTTP_REQ_POST))
467 start_send_data (hs, HTTP_STATUS_METHOD_NOT_ALLOWED);
474 vec_validate (request, msg.data.len - 1);
475 rv = svm_fifo_dequeue (ts->rx_fifo, msg.data.len, request);
476 ASSERT (rv == msg.data.len);
477 /* request must be a proper C-string in addition to a vector */
478 vec_add1 (request, 0);
481 /* Find and send data */
482 handle_request (hs, msg.method_type, request);
490 hss_ts_tx_callback (session_t *ts)
496 hs = hss_session_get (ts->thread_index, ts->opaque);
497 if (!hs || !hs->data)
500 to_send = hs->data_len - hs->data_offset;
501 rv = svm_fifo_enqueue (ts->tx_fifo, to_send, hs->data + hs->data_offset);
505 svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
511 hs->data_offset += rv;
512 svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
515 if (svm_fifo_set_event (ts->tx_fifo))
516 session_send_io_evt_to_thread (ts->tx_fifo, SESSION_IO_EVT_TX);
521 /** \brief Session accept callback
524 hss_ts_accept_callback (session_t *ts)
529 hs = hss_session_alloc (ts->thread_index);
531 hs->vpp_session_index = ts->session_index;
532 hs->vpp_session_handle = session_handle (ts);
534 /* The application sets a threshold for it's fifo to get notified when
535 * additional data can be enqueued. We want to keep the TX fifo reasonably
536 * full, however avoid entering a state where the
537 * fifo is full all the time and small chunks of data are being enqueued
538 * each time. If the fifo is small (under 16K) we set
539 * the threshold to it's size, meaning a notification will be given when the
542 thresh = clib_min (svm_fifo_size (ts->tx_fifo), HSS_FIFO_THRESH);
543 svm_fifo_set_deq_thresh (ts->tx_fifo, thresh);
545 ts->opaque = hs->session_index;
546 ts->session_state = SESSION_STATE_READY;
551 hss_ts_disconnect_callback (session_t *ts)
553 hss_main_t *hsm = &hss_main;
554 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
556 a->handle = session_handle (ts);
557 a->app_index = hsm->app_index;
558 vnet_disconnect_session (a);
562 hss_ts_reset_callback (session_t *ts)
564 hss_main_t *hsm = &hss_main;
565 vnet_disconnect_args_t _a = { 0 }, *a = &_a;
567 a->handle = session_handle (ts);
568 a->app_index = hsm->app_index;
569 vnet_disconnect_session (a);
573 hss_ts_connected_callback (u32 app_index, u32 api_context, session_t *ts,
576 clib_warning ("called...");
581 hss_add_segment_callback (u32 client_index, u64 segment_handle)
587 hss_ts_cleanup (session_t *s, session_cleanup_ntf_t ntf)
589 hss_main_t *hsm = &hss_main;
592 if (ntf == SESSION_CLEANUP_TRANSPORT)
595 hs = hss_session_get (s->thread_index, s->opaque);
599 if (hs->cache_pool_index != ~0)
601 hss_cache_detach_entry (&hsm->cache, hs->cache_pool_index);
602 hs->cache_pool_index = ~0;
612 hss_session_free (hs);
615 static session_cb_vft_t hss_cb_vft = {
616 .session_accept_callback = hss_ts_accept_callback,
617 .session_disconnect_callback = hss_ts_disconnect_callback,
618 .session_connected_callback = hss_ts_connected_callback,
619 .add_segment_callback = hss_add_segment_callback,
620 .builtin_app_rx_callback = hss_ts_rx_callback,
621 .builtin_app_tx_callback = hss_ts_tx_callback,
622 .session_reset_callback = hss_ts_reset_callback,
623 .session_cleanup_callback = hss_ts_cleanup,
629 vnet_app_add_cert_key_pair_args_t _ck_pair, *ck_pair = &_ck_pair;
630 hss_main_t *hsm = &hss_main;
631 u64 options[APP_OPTIONS_N_OPTIONS];
632 vnet_app_attach_args_t _a, *a = &_a;
633 u32 segment_size = 128 << 20;
635 clib_memset (a, 0, sizeof (*a));
636 clib_memset (options, 0, sizeof (options));
638 if (hsm->private_segment_size)
639 segment_size = hsm->private_segment_size;
641 a->api_client_index = ~0;
642 a->name = format (0, "http_static_server");
643 a->session_cb_vft = &hss_cb_vft;
644 a->options = options;
645 a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
646 a->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
647 a->options[APP_OPTIONS_RX_FIFO_SIZE] =
648 hsm->fifo_size ? hsm->fifo_size : 8 << 10;
649 a->options[APP_OPTIONS_TX_FIFO_SIZE] =
650 hsm->fifo_size ? hsm->fifo_size : 32 << 10;
651 a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
652 a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = hsm->prealloc_fifos;
653 a->options[APP_OPTIONS_TLS_ENGINE] = CRYPTO_ENGINE_OPENSSL;
655 if (vnet_application_attach (a))
658 clib_warning ("failed to attach server");
662 hsm->app_index = a->app_index;
664 clib_memset (ck_pair, 0, sizeof (*ck_pair));
665 ck_pair->cert = (u8 *) test_srv_crt_rsa;
666 ck_pair->key = (u8 *) test_srv_key_rsa;
667 ck_pair->cert_len = test_srv_crt_rsa_len;
668 ck_pair->key_len = test_srv_key_rsa_len;
669 vnet_app_add_cert_key_pair (ck_pair);
670 hsm->ckpair_index = ck_pair->index;
676 hss_transport_needs_crypto (transport_proto_t proto)
678 return proto == TRANSPORT_PROTO_TLS || proto == TRANSPORT_PROTO_DTLS ||
679 proto == TRANSPORT_PROTO_QUIC;
685 hss_main_t *hsm = &hss_main;
686 session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL;
687 vnet_listen_args_t _a, *a = &_a;
688 char *uri = "tcp://0.0.0.0/80";
692 clib_memset (a, 0, sizeof (*a));
693 a->app_index = hsm->app_index;
696 uri = (char *) hsm->uri;
698 if (parse_uri (uri, &sep))
701 need_crypto = hss_transport_needs_crypto (sep.transport_proto);
703 sep.transport_proto = TRANSPORT_PROTO_HTTP;
704 clib_memcpy (&a->sep_ext, &sep, sizeof (sep));
708 session_endpoint_alloc_ext_cfg (&a->sep_ext,
709 TRANSPORT_ENDPT_EXT_CFG_CRYPTO);
710 a->sep_ext.ext_cfg->crypto.ckpair_index = hsm->ckpair_index;
713 rv = vnet_listen (a);
716 clib_mem_free (a->sep_ext.ext_cfg);
722 hss_url_handlers_init (hss_main_t *hsm)
724 if (!hsm->get_url_handlers)
726 hsm->get_url_handlers = hash_create_string (0, sizeof (uword));
727 hsm->post_url_handlers = hash_create_string (0, sizeof (uword));
730 hss_builtinurl_json_handlers_init ();
734 hss_create (vlib_main_t *vm)
736 vlib_thread_main_t *vtm = vlib_get_thread_main ();
737 hss_main_t *hsm = &hss_main;
740 num_threads = 1 /* main thread */ + vtm->n_threads;
741 vec_validate (hsm->sessions, num_threads - 1);
745 clib_warning ("failed to attach server");
750 clib_warning ("failed to start listening");
755 hss_cache_init (&hsm->cache, hsm->cache_size, hsm->debug_level);
757 if (hsm->enable_url_handlers)
758 hss_url_handlers_init (hsm);
763 static clib_error_t *
764 hss_create_command_fn (vlib_main_t *vm, unformat_input_t *input,
765 vlib_cli_command_t *cmd)
767 unformat_input_t _line_input, *line_input = &_line_input;
768 hss_main_t *hsm = &hss_main;
769 clib_error_t *error = 0;
773 if (hsm->app_index != (u32) ~0)
774 return clib_error_return (0, "http server already running...");
776 hsm->prealloc_fifos = 0;
777 hsm->private_segment_size = 0;
779 hsm->cache_size = 10 << 20;
781 /* Get a line of input. */
782 if (!unformat_user (input, unformat_line_input, line_input))
785 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
787 if (unformat (line_input, "www-root %s", &hsm->www_root))
790 if (unformat (line_input, "prealloc-fifos %d", &hsm->prealloc_fifos))
792 else if (unformat (line_input, "private-segment-size %U",
793 unformat_memory_size, &seg_size))
794 hsm->private_segment_size = seg_size;
795 else if (unformat (line_input, "fifo-size %d", &hsm->fifo_size))
796 hsm->fifo_size <<= 10;
797 else if (unformat (line_input, "cache-size %U", unformat_memory_size,
800 else if (unformat (line_input, "uri %s", &hsm->uri))
802 else if (unformat (line_input, "debug %d", &hsm->debug_level))
804 else if (unformat (line_input, "debug"))
805 hsm->debug_level = 1;
806 else if (unformat (line_input, "ptr-thresh %U", unformat_memory_size,
807 &hsm->use_ptr_thresh))
809 else if (unformat (line_input, "url-handlers"))
810 hsm->enable_url_handlers = 1;
813 error = clib_error_return (0, "unknown input `%U'",
814 format_unformat_error, line_input);
819 unformat_free (line_input);
826 if (hsm->www_root == 0 && !hsm->enable_url_handlers)
828 error = clib_error_return (0, "Must set www-root or url-handlers");
832 if (hsm->cache_size < (128 << 10))
834 error = clib_error_return (0, "cache-size must be at least 128kb");
835 vec_free (hsm->www_root);
839 vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
841 if ((rv = hss_create (vm)))
843 error = clib_error_return (0, "server_create returned %d", rv);
844 vec_free (hsm->www_root);
853 * Enable the static http server
856 * This command enables the static http server. Only the www-root
857 * parameter is required
859 * http static server www-root /tmp/www uri tcp://0.0.0.0/80 cache-size 2m
861 * @cliexcmd{http static server www-root <path> [prealloc-fios <nn>]
862 * [private-segment-size <nnMG>] [fifo-size <nbytes>] [uri <uri>]}
864 VLIB_CLI_COMMAND (hss_create_command, static) = {
865 .path = "http static server",
867 "http static server www-root <path> [prealloc-fifos <nn>]\n"
868 "[private-segment-size <nnMG>] [fifo-size <nbytes>] [uri <uri>]\n"
869 "[ptr-thresh <nn>] [url-handlers] [debug [nn]]\n",
870 .function = hss_create_command_fn,
874 format_hss_session (u8 *s, va_list *args)
876 hss_session_t *hs = va_arg (*args, hss_session_t *);
877 int __clib_unused verbose = va_arg (*args, int);
879 s = format (s, "\n path %s, data length %u, data_offset %u",
880 hs->path ? hs->path : (u8 *) "[none]", hs->data_len,
885 static clib_error_t *
886 hss_show_command_fn (vlib_main_t *vm, unformat_input_t *input,
887 vlib_cli_command_t *cmd)
889 int verbose = 0, show_cache = 0, show_sessions = 0;
890 hss_main_t *hsm = &hss_main;
892 if (hsm->www_root == 0)
893 return clib_error_return (0, "Static server disabled");
895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
897 if (unformat (input, "verbose %d", &verbose))
899 else if (unformat (input, "verbose"))
901 else if (unformat (input, "cache"))
903 else if (unformat (input, "sessions"))
909 if ((show_cache + show_sessions) == 0)
910 return clib_error_return (0, "specify one or more of cache, sessions");
913 vlib_cli_output (vm, "%U", format_hss_cache, &hsm->cache, verbose);
917 u32 *session_indices = 0;
922 for (i = 0; i < vec_len (hsm->sessions); i++)
924 pool_foreach (hs, hsm->sessions[i])
925 vec_add1 (session_indices, hs - hsm->sessions[i]);
927 for (j = 0; j < vec_len (session_indices); j++)
930 vm, "%U", format_hss_session,
931 pool_elt_at_index (hsm->sessions[i], session_indices[j]),
934 vec_reset_length (session_indices);
936 vec_free (session_indices);
942 * Display static http server cache statistics
945 * This command shows the contents of the static http server cache
947 * show http static server
949 * @cliexcmd{show http static server sessions cache [verbose [nn]]}
951 VLIB_CLI_COMMAND (hss_show_command, static) = {
952 .path = "show http static server",
953 .short_help = "show http static server sessions cache [verbose [<nn>]]",
954 .function = hss_show_command_fn,
957 static clib_error_t *
958 hss_clear_cache_command_fn (vlib_main_t *vm, unformat_input_t *input,
959 vlib_cli_command_t *cmd)
961 hss_main_t *hsm = &hss_main;
964 if (hsm->www_root == 0)
965 return clib_error_return (0, "Static server disabled");
967 busy_items = hss_cache_clear (&hsm->cache);
970 vlib_cli_output (vm, "Note: %d busy items still in cache...", busy_items);
972 vlib_cli_output (vm, "Cache cleared...");
977 * Clear the static http server cache, to force the server to
978 * reload content from backing files
981 * This command clear the static http server cache
983 * clear http static cache
985 * @cliexcmd{clear http static cache}
987 VLIB_CLI_COMMAND (clear_hss_cache_command, static) = {
988 .path = "clear http static cache",
989 .short_help = "clear http static cache",
990 .function = hss_clear_cache_command_fn,
993 static clib_error_t *
994 hss_main_init (vlib_main_t *vm)
996 hss_main_t *hsm = &hss_main;
1001 /* Set up file extension to mime type index map */
1002 hsm->mime_type_indices_by_file_extensions =
1003 hash_create_string (0, sizeof (uword));
1005 #define _(def, ext, str) \
1006 hash_set_mem (hsm->mime_type_indices_by_file_extensions, ext, \
1007 HTTP_CONTENT_##def);
1008 foreach_http_content_type;
1014 VLIB_INIT_FUNCTION (hss_main_init);
1017 * fd.io coding-style-patch-verification: ON
1020 * eval: (c-set-style "gnu")