重构cache目录,将libxml2、libcurl放到vendor目录。

This commit is contained in:
zhengchao
2018-10-14 17:11:45 +08:00
parent cb27db40f2
commit 12d4370b3f
120 changed files with 508 additions and 29642 deletions

View File

@@ -1,4 +1,4 @@
#include"proxy_cache.h"
#include"tango_cache_pending.h"
#include<assert.h>
#include<string.h>
#include<stdlib.h>
@@ -63,19 +63,17 @@ enum cache_pending_action request_cache_control(const char* value, struct reques
}
bool cache_vertify(const struct tfe_http_field *http_fields, size_t n_fields)
bool cache_vertify(const struct tfe_http_half *request)
{
int i = 0;
for (; i < n_fields; i++)
{
if ( http_fields[i].http_field == TLF_HTTP_IF_MATCH ||
http_fields[i].http_field == TLF_HTTP_IF_NONE_MATCH ||
http_fields[i].http_field == TLF_HTTP_IF_MODIFIED_SINCE ||
http_fields[i].http_field == TLF_HTTP_IF_UNMODIFIED_SINCE )
{
return true;
}
}
if( !tfe_http_std_field_read(request,TFE_HTTP_IF_MATCH) ||
!tfe_http_std_field_read(request,TFE_HTTP_IF_NONE_MATCH) ||
!tfe_http_std_field_read(request,TFE_HTTP_IF_MODIFIED_SINCE) ||
!tfe_http_std_field_read(request,TFE_HTTP_IF_UNMODIFIED_SINCE)
)
{
return true;
}
return false;
}
@@ -105,28 +103,28 @@ enum cache_pending_action get_pragma_action(const char * value)
}
enum cache_pending_action tfe_cache_get_pending(const struct tfe_http_field *request, size_t n_fields, struct request_freshness* restrict)
enum cache_pending_action tfe_cache_get_pending(const struct tfe_http_half *request, struct request_freshness* restrict)
{
enum cache_pending_action res = UNDEFINED;
int i = 0;
int index = 0;
const char *value = NULL;
memset(restrict,0,sizeof(struct request_freshness));
value = get_head_value(request, n_fields, TFE_HTTP_PRAGMA);
value = tfe_http_std_field_read(request, TFE_HTTP_PRAGMA);
if (value != NULL)
{
res = get_pragma_action(value);
}
else
{
value = get_head_value(request, n_fields, TFE_HTTP_CACHE_CONTROL);
value = tfe_http_std_field_read(request, TFE_HTTP_CACHE_CONTROL);
if (value != NULL)
{
res = request_cache_control(value, restrict);
}
else
{
if (cache_vertify(request, n_fields))
if (cache_vertify(request))
{
res = VERIFY;
}
@@ -199,13 +197,13 @@ time_t get_response_maxage(const char* cache_ctl)
}
void get_response_freshness(const struct tfe_http_field *response, size_t n_fields, struct response_freshness* freshness)
void get_response_freshness(const struct tfe_http_half *response, struct response_freshness* freshness)
{
time_t expire_rel_time = 0;
time_t cur_rel_time = 0;
struct tm cur_gmt_time;
const char* field_value = NULL;
field_value = get_head_value(response, n_fields, TFE_HTTP_CACHE_CONTROL);
field_value = tfe_http_std_field_read(response, TFE_HTTP_CACHE_CONTROL);
if (field_value != NULL)
{
freshness->timeout = get_response_s_maxage(field_value);
@@ -216,7 +214,7 @@ void get_response_freshness(const struct tfe_http_field *response, size_t n_fiel
}
else
{
field_value = get_head_value(response, n_fields, TFE_HTTP_EXPIRES);
field_value = tfe_http_std_field_read(response, TFE_HTTP_EXPIRES);
if (field_value != NULL)
{
assert(is_standard_gmt_format(field_value));
@@ -230,13 +228,13 @@ void get_response_freshness(const struct tfe_http_field *response, size_t n_fiel
freshness->timeout = expire_rel_time - cur_rel_time;
}
}
field_value = get_head_value(response, n_fields, TFE_HTTP_DATE);
field_value = tfe_http_std_field_read(response, TFE_HTTP_DATE);
if (field_value != NULL)
{
assert(is_standard_gmt_format(field_value));
freshness->date = absolute_to_relative_time(field_value);;
}
field_value = get_head_value(response, n_fields, TLF_HTTP_LAST_MODIFIED);
field_value = tfe_http_std_field_read(response, TFE_HTTP_LAST_MODIFIED);
if (field_value != NULL)
{
assert(is_standard_gmt_format(field_value));
@@ -268,28 +266,28 @@ enum cache_pending_action response_cache_control(const char* value)
}
enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_field *response, size_t n_fields, struct response_freshness* freshness)
enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_half *response, struct response_freshness* freshness)
{
enum cache_pending_action res = UNDEFINED;
int i = 0;
int index = 0;
const char *value = NULL;
memset(freshness,0,sizeof(struct response_freshness));
value = get_head_value(response, n_fields, TFE_HTTP_PRAGMA);
value = tfe_http_std_field_read(response, TFE_HTTP_PRAGMA);
if (value != NULL)
{
res = get_pragma_action(value);
}
else
{
value = get_head_value(response, n_fields, TFE_HTTP_CACHE_CONTROL);
value = tfe_http_std_field_read(response, TFE_HTTP_CACHE_CONTROL);
if (value != NULL)
{
res = response_cache_control(value);
}
else
{
value = get_head_value(response, n_fields, TFE_HTTP_EXPIRES);
value = tfe_http_std_field_read(response, TFE_HTTP_EXPIRES);
if (value != NULL)
{
res = ALLOWED;
@@ -298,7 +296,7 @@ enum cache_pending_action tfe_cache_put_pending(const struct tfe_http_field *res
}
if (res == ALLOWED)
{
get_response_freshness(response, n_fields, freshness);
get_response_freshness(response, freshness);
}
return res;
}