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/cache/include/tango_cache_pending.h

65 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include<time.h>
#include<tfe_http.h>
enum cache_pending_action {
UNDEFINED = 0,
ALLOWED,
FORBIDDEN,
REVALIDATE
};
struct tfe_http_field {
enum tfe_http_std_field http_field;
const char* value;
};
struct request_freshness {
time_t min_fresh;
time_t max_age;
};
struct response_freshness{
time_t date;
time_t last_modified;
time_t timeout;
};
time_t read_GMT_time(const char* gmt_string);
/*
:
request:HTTP请求字段信息Pragma,Cache-Control,If-Match,If-None-Match,If-Modified-Since,If-Unmodified-Since字段
n_fields:request包含的HTTP请求字段数目
restrict:ALLOWEDCache-Control字段包括的min-fresh或者max-age值0
UNDEFINED = 0,//请求字段中未定义缓存的行为
ALLOWED ,//允许使用缓存作为该请求的响应
FORBIDDEN,//禁止使用缓存作为该请求的响应,需要向源服务器请求
REVALIDATE,//禁止使用未验证有效性的缓存作为该请求的响应
*/
enum cache_pending_action tfe_cache_get_pending(const struct tfe_http_half *request, struct request_freshness* restrict);
/*
date或者last-modified值作为传出参数返回给调用者
:
response:HTTP响应字段信息Pragma,Cache-Control,ExpiresDateLast-Modified字段
n_fields:response包含的HTTP响应字段数目
freshness:ALLOWEDCache-Control字段的s-maxage/max-age值以及Date字段Last-Modified字段相对时间
UNDEFINED = 0,//响应字段中未定义缓存的行为
ALLOWED ,//允许缓存该响应
FORBIDDEN,//禁止缓存该响应
*/
enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_half *response, struct response_freshness* freshness);