This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/plugin/business/tsg-http/include/tsg_proxy_web_cache.h

70 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include <event2/event.h>
#include <event2/buffer.h>
#include <tfe_future.h>
2023-03-30 19:39:18 +08:00
#include <MESA/maat.h>
struct cache_handle;
2023-03-30 19:39:18 +08:00
struct cache_handle* create_web_cache_handle(const char* profile_path, const char* section,
struct event_base* gc_evbase, struct maat *feather, void *logger);
struct cached_meta
{
size_t content_length;
2018-10-14 18:45:02 +08:00
char* content_type;
2018-10-25 18:45:33 +08:00
char* last_modified;
char* etag;
};
2018-10-25 18:45:33 +08:00
const struct cached_meta* cache_query_result_read_meta(future_result_t * result);
size_t cache_query_result_get_data(future_result_t * result, const unsigned char** pp_data);
int web_cache_async_read(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_half * request, struct cache_mid** mid, struct future* f);
2018-10-25 18:45:33 +08:00
enum cache_query_result_type
{
CACHE_QUERY_RESULT_MISS,
CACHE_QUERY_RESULT_META,
CACHE_QUERY_RESULT_DATA,
CACHE_QUERY_RESULT_END,
CACHE_QUERY_RESULT_IRRELEVANT,
__CACHE_QUERY_RESULT_MAX
};
enum cache_query_result_type cache_query_result_get_type(future_result_t * result);
2018-10-25 18:45:33 +08:00
enum cache_pending_result
{
PENDING_RESULT_NONE=0,
PENDING_RESULT_FOBIDDEN,
PENDING_RESULT_REVALIDATE,
PENDING_RESULT_ALLOWED,
PENDING_RESULT_HIT,
2018-10-25 18:45:33 +08:00
PENDING_RESULT_MISS
};
const char* cache_pending_result_string(enum cache_pending_result);
struct cache_mid;
void cache_mid_clear(struct cache_mid **mid);
const struct cached_meta* cache_pending_result_read_meta(future_result_t * result, struct cache_mid* mid);
2018-10-25 18:45:33 +08:00
enum cache_pending_result web_cache_async_pending(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_half * request, struct cache_mid **mid, struct future* f_revalidate);
2018-10-25 18:45:33 +08:00
struct cache_write_context;
2023-03-30 19:39:18 +08:00
struct cache_write_context* web_cache_write_start(struct cache_handle* handle, unsigned int thread_id,
const struct tfe_http_session * session, struct cache_mid **mid);
void web_cache_write(struct cache_write_context* ctx, const unsigned char * body_frag, size_t frag_size);
//return 1 on success
//return -1 on failed
//return -2 on cancel
int web_cache_write_end(struct cache_write_context* ctx);