#include <vppinfra/hash.h>
#include <vppinfra/error.h>
-#include <vppinfra/bihash_vec8_8.h>
+#include <http_static/http_cache.h>
/** @file http_static.h
* Static http server definitions
/** Data to send */
u8 *data;
/** Data length */
- u32 data_len;
+ u64 data_len;
/** Current data send offset */
u32 data_offset;
/** Need to free data in detach_cache_entry */
int free_data;
/** File cache pool index */
u32 cache_pool_index;
+ /** Content type, e.g. text, text/javascript, etc. */
+ http_content_type_t content_type;
} hss_session_t;
typedef struct hss_session_handle_
STATIC_ASSERT_SIZEOF (hss_session_handle_t, sizeof (u64));
-/** \brief In-memory file data cache entry
- */
-typedef struct
-{
- /** Name of the file */
- u8 *filename;
- /** Contents of the file, as a u8 * vector */
- u8 *data;
- /** Last time the cache entry was used */
- f64 last_used;
- /** Cache LRU links */
- u32 next_index;
- u32 prev_index;
- /** Reference count, so we don't recycle while referenced */
- int inuse;
-} hss_cache_entry_t;
typedef struct hss_url_handler_args_
{
/* Request args */
struct
{
- u8 *request;
- http_req_method_t reqtype;
+ u8 *query;
+ u8 *req_data;
+ http_req_method_t req_type;
};
/* Reply args */
{
/** Per thread vector of session pools */
hss_session_t **sessions;
- /** Session pool reader writer lock */
- clib_spinlock_t cache_lock;
-
- /** Unified file data cache pool */
- hss_cache_entry_t *cache_pool;
- /** Hash table which maps file name to file data */
- BVT (clib_bihash) name_to_data;
/** Hash tables for built-in GET and POST handlers */
uword *get_url_handlers;
uword *post_url_handlers;
- /** Current cache size */
- u64 cache_size;
- /** Max cache size in bytes */
- u64 cache_limit;
- /** Number of cache evictions */
- u64 cache_evictions;
-
- /** Cache LRU listheads */
- u32 first_index;
- u32 last_index;
+ hss_cache_t cache;
/** root path to be served */
u8 *www_root;
/** The bind URI, defaults to tcp://0.0.0.0/80 */
u8 *uri;
/** Threshold for switching to ptr data in http msgs */
- u32 use_ptr_thresh;
+ u64 use_ptr_thresh;
/** Enable the use of builtinurls */
u8 enable_url_handlers;
+ /** Max cache size before LRU occurs */
+ u64 cache_size;
+
+ /** hash table of file extensions to mime types string indices */
+ uword *mime_type_indices_by_file_extensions;
} hss_main_t;
extern hss_main_t hss_main;
http_req_method_t type);
void hss_session_send_data (hss_url_handler_args_t *args);
void hss_builtinurl_json_handlers_init (void);
+hss_session_t *hss_session_get (u32 thread_index, u32 hs_index);
#endif /* __included_http_static_h__ */