|
|
|
@@ -113,7 +113,7 @@ TAILQ_LIST_FIND(struct tfe_h2_stream *h2_stream_info, int32_t stream_id)
|
|
|
|
return stream;
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
tfe_h2_header_add_field(struct tfe_h2_header *h2_header, const struct http_field_name * field, const char * value, int at_tail)
|
|
|
|
tfe_h2_header_add_field(struct tfe_h2_header *h2_header, const struct http_field_name * field, const char * value, int at_tail)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct tfe_h2_field *peer_h2_field = ALLOC(struct tfe_h2_field, 1);
|
|
|
|
struct tfe_h2_field *peer_h2_field = ALLOC(struct tfe_h2_field, 1);
|
|
|
|
@@ -137,6 +137,32 @@ tfe_h2_header_add_field(struct tfe_h2_header *h2_header, const struct http_field
|
|
|
|
TAILQ_INSERT_HEAD(&h2_header->h2_field_list, peer_h2_field, next);
|
|
|
|
TAILQ_INSERT_HEAD(&h2_header->h2_field_list, peer_h2_field, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static nghttp2_nv*
|
|
|
|
|
|
|
|
tfe_h2_header_modify_field(struct tfe_h2_header *header, nghttp2_nv *hdrs, const char *field_name, const char *filed_value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int nvlen = 0;
|
|
|
|
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TAILQ_FOREACH_SAFE(h2_field, &header->h2_field_list, next, peer_h2_field)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hdrs[nvlen].name = h2_field->nv.name;
|
|
|
|
|
|
|
|
hdrs[nvlen].namelen = h2_field->nv.namelen;
|
|
|
|
|
|
|
|
if (filed_value && (0==strcasecmp((const char*)h2_field->nv.name, field_name)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hdrs[nvlen].value = (uint8_t *)filed_value;
|
|
|
|
|
|
|
|
hdrs[nvlen].valuelen = strlen(filed_value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hdrs[nvlen].value = h2_field->nv.value;
|
|
|
|
|
|
|
|
hdrs[nvlen].valuelen = h2_field->nv.valuelen;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hdrs[nvlen].flags = h2_field->nv.flags;
|
|
|
|
|
|
|
|
nvlen++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return hdrs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
static inline void
|
|
|
|
headers_init(struct tfe_h2_header *header)
|
|
|
|
headers_init(struct tfe_h2_header *header)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -169,12 +195,12 @@ method_to_str_idx(const char * method)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static nghttp2_nv*
|
|
|
|
static nghttp2_nv*
|
|
|
|
nghttp2_nv_packet(struct tfe_h2_header *header, nghttp2_nv *hdrs)
|
|
|
|
tfe_h2_header_convert_nv(struct tfe_h2_header *header, nghttp2_nv *hdrs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int nvlen = 0;
|
|
|
|
int nvlen = 0;
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
TAILQ_FOREACH_SAFE(h2_field, &header->h2_field_list, next, peer_h2_field){
|
|
|
|
TAILQ_FOREACH_SAFE(h2_field, &header->h2_field_list, next, peer_h2_field){
|
|
|
|
hdrs[nvlen].name = h2_field->nv.name;
|
|
|
|
hdrs[nvlen].name = h2_field->nv.name;
|
|
|
|
hdrs[nvlen].namelen = h2_field->nv.namelen;
|
|
|
|
hdrs[nvlen].namelen = h2_field->nv.namelen;
|
|
|
|
hdrs[nvlen].value = h2_field->nv.value;
|
|
|
|
hdrs[nvlen].value = h2_field->nv.value;
|
|
|
|
@@ -238,7 +264,7 @@ delete_nv_packet_data(struct tfe_h2_header *header)
|
|
|
|
|
|
|
|
|
|
|
|
free(h2_filed->field);
|
|
|
|
free(h2_filed->field);
|
|
|
|
h2_filed->field = NULL;
|
|
|
|
h2_filed->field = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
free(h2_filed);
|
|
|
|
free(h2_filed);
|
|
|
|
h2_filed = NULL;
|
|
|
|
h2_filed = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -267,15 +293,15 @@ void half_set_callback(struct tfe_h2_half_private * half_private,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * h2_half_ops_field_read(const struct tfe_http_half * half, const struct http_field_name * field)
|
|
|
|
const char * h2_half_ops_field_read(const struct tfe_http_half * half, const struct http_field_name * field)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const struct tfe_h2_half_private *half_private = nghttp2_to_half_private(half);
|
|
|
|
const struct tfe_h2_half_private *half_private = nghttp2_to_half_private(half);
|
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(half_private == NULL))
|
|
|
|
if (unlikely(half_private == NULL))
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
struct tfe_h2_field *h2_field=NULL, *peer_h2_field=NULL;
|
|
|
|
struct tfe_h2_field *h2_field=NULL, *peer_h2_field=NULL;
|
|
|
|
const struct tfe_h2_header *h2_header =&(half_private->header);
|
|
|
|
const struct tfe_h2_header *h2_header =&(half_private->header);
|
|
|
|
|
|
|
|
|
|
|
|
TAILQ_FOREACH(h2_field, &h2_header->h2_field_list, next)
|
|
|
|
TAILQ_FOREACH(h2_field, &h2_header->h2_field_list, next)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (http_field_name_compare(h2_field->field, field) != 0) continue;
|
|
|
|
if (http_field_name_compare(h2_field->field, field) != 0) continue;
|
|
|
|
@@ -297,7 +323,7 @@ int h2_half_ops_field_write(struct tfe_http_half * half, const struct http_field
|
|
|
|
if (http_field_name_compare(h2_field->field, field) != 0) continue;
|
|
|
|
if (http_field_name_compare(h2_field->field, field) != 0) continue;
|
|
|
|
peer_h2_field = h2_field;
|
|
|
|
peer_h2_field = h2_field;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (peer_h2_field != NULL && value != NULL)
|
|
|
|
if (peer_h2_field != NULL && value != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -334,7 +360,7 @@ h2_half_ops_allow_write(const struct tfe_http_half * half)
|
|
|
|
const char * h2_half_ops_field_iterate(const struct tfe_http_half * half, void ** iter, struct http_field_name * field)
|
|
|
|
const char * h2_half_ops_field_iterate(const struct tfe_http_half * half, void ** iter, struct http_field_name * field)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct tfe_h2_field **h2_filed = (struct tfe_h2_field **)iter;
|
|
|
|
struct tfe_h2_field **h2_filed = (struct tfe_h2_field **)iter;
|
|
|
|
const struct tfe_h2_half_private *half_private = nghttp2_to_half_private(half);
|
|
|
|
const struct tfe_h2_half_private *half_private = nghttp2_to_half_private(half);
|
|
|
|
const struct tfe_h2_header *header = &half_private->header;
|
|
|
|
const struct tfe_h2_header *header = &half_private->header;
|
|
|
|
|
|
|
|
|
|
|
|
if (*h2_filed == NULL)
|
|
|
|
if (*h2_filed == NULL)
|
|
|
|
@@ -400,6 +426,7 @@ void delete_stream_half_data(struct tfe_h2_half_private **data,
|
|
|
|
if ((*data)->url_storage)
|
|
|
|
if ((*data)->url_storage)
|
|
|
|
FREE(&((*data)->url_storage));
|
|
|
|
FREE(&((*data)->url_storage));
|
|
|
|
delete_nv_packet_data(&((*data)->header));
|
|
|
|
delete_nv_packet_data(&((*data)->header));
|
|
|
|
|
|
|
|
|
|
|
|
if((*data)->event_cb_user_deleter != NULL)
|
|
|
|
if((*data)->event_cb_user_deleter != NULL)
|
|
|
|
(*data)->event_cb_user_deleter((*data)->event_cb_user);
|
|
|
|
(*data)->event_cb_user_deleter((*data)->event_cb_user);
|
|
|
|
free(*data);
|
|
|
|
free(*data);
|
|
|
|
@@ -456,7 +483,7 @@ int h2_half_ops_body_data(struct tfe_http_half * h2_response, const unsigned cha
|
|
|
|
int xret = -1;
|
|
|
|
int xret = -1;
|
|
|
|
struct tfe_h2_half_private * h2_resp_priv = nghttp2_to_half_private(h2_response);
|
|
|
|
struct tfe_h2_half_private * h2_resp_priv = nghttp2_to_half_private(h2_response);
|
|
|
|
struct tfe_h2_payload *body = &h2_resp_priv->body;
|
|
|
|
struct tfe_h2_payload *body = &h2_resp_priv->body;
|
|
|
|
|
|
|
|
|
|
|
|
if (body->gzip != HTTP2_CONTENT_ENCODING_NONE){
|
|
|
|
if (body->gzip != HTTP2_CONTENT_ENCODING_NONE){
|
|
|
|
|
|
|
|
|
|
|
|
xret = deflate_write(&body->deflate, (const uint8_t *)data, sz_data,
|
|
|
|
xret = deflate_write(&body->deflate, (const uint8_t *)data, sz_data,
|
|
|
|
@@ -647,7 +674,7 @@ upstream_read_callback(nghttp2_session *session, int32_t stream_id,
|
|
|
|
|
|
|
|
|
|
|
|
static enum tfe_stream_action
|
|
|
|
static enum tfe_stream_action
|
|
|
|
nghttp2_server_frame_submit_response(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
nghttp2_server_frame_submit_response(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
struct tfe_h2_session *h2_session)
|
|
|
|
struct tfe_h2_session *h2_session)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
int rv = -1;
|
|
|
|
struct tfe_h2_header *h2_header = NULL;
|
|
|
|
struct tfe_h2_header *h2_header = NULL;
|
|
|
|
@@ -666,15 +693,20 @@ nghttp2_server_frame_submit_response(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
char str_sz_evbuf_body[TFE_STRING_MAX];
|
|
|
|
char str_sz_evbuf_body[TFE_STRING_MAX];
|
|
|
|
snprintf(str_sz_evbuf_body, sizeof(str_sz_evbuf_body) - 1, "%lu", evbuffer_get_length(body->evbuf_body));
|
|
|
|
snprintf(str_sz_evbuf_body, sizeof(str_sz_evbuf_body) - 1, "%lu", evbuffer_get_length(body->evbuf_body));
|
|
|
|
|
|
|
|
|
|
|
|
const static struct http_field_name __cont_encoding_length_name = {TFE_HTTP_CONT_LENGTH, NULL};
|
|
|
|
const static struct http_field_name encoding_field = {TFE_HTTP_CONT_LENGTH, NULL};
|
|
|
|
tfe_http_field_write(&pangu_resp->half_public, &__cont_encoding_length_name, str_sz_evbuf_body);
|
|
|
|
tfe_http_field_write(&pangu_resp->half_public, &encoding_field, str_sz_evbuf_body);
|
|
|
|
|
|
|
|
|
|
|
|
nghttp2_data_provider data_prd;
|
|
|
|
nghttp2_data_provider data_prd;
|
|
|
|
data_prd.source.ptr = (void *)body;
|
|
|
|
data_prd.source.ptr = (void *)body;
|
|
|
|
data_prd.read_callback = upstream_read_callback;
|
|
|
|
data_prd.read_callback = upstream_read_callback;
|
|
|
|
|
|
|
|
|
|
|
|
nghttp2_nv hdrs[h2_header->nvlen];
|
|
|
|
nghttp2_nv hdrs[h2_header->nvlen];
|
|
|
|
rv = nghttp2_submit_response(h2_stream_info->as_server, h2_session->ngh2_stream_id, nghttp2_nv_packet(h2_header, hdrs),
|
|
|
|
/*Adapt Http uri Settings**/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tfe_http_field_write(&pangu_resp->half_public, &encoding_field, str_sz_evbuf_body);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rv = nghttp2_submit_response(h2_stream_info->as_server, h2_session->ngh2_stream_id, tfe_h2_header_convert_nv(h2_header, hdrs),
|
|
|
|
h2_header->nvlen, &data_prd);
|
|
|
|
h2_header->nvlen, &data_prd);
|
|
|
|
if (rv != 0){
|
|
|
|
if (rv != 0){
|
|
|
|
return ACTION_FORWARD_DATA;
|
|
|
|
return ACTION_FORWARD_DATA;
|
|
|
|
@@ -1003,10 +1035,10 @@ nghttp2_submit_end_header(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
if (headers.nvlen <= 0 || ((headers.flag & NGHTTP2_FLAG_END_STREAM)!=1) ){
|
|
|
|
if (headers.nvlen <= 0 || ((headers.flag & NGHTTP2_FLAG_END_STREAM)!=1) ){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nghttp2_nv hdrs[headers.nvlen];
|
|
|
|
nghttp2_nv hdrs[headers.nvlen];
|
|
|
|
stream_id = nghttp2_submit_headers(h2_stream_info->as_server, headers.flag,
|
|
|
|
stream_id = nghttp2_submit_headers(h2_stream_info->as_server, headers.flag,
|
|
|
|
h2_session->ngh2_stream_id, NULL, nghttp2_nv_packet(&headers, hdrs),
|
|
|
|
h2_session->ngh2_stream_id, NULL, tfe_h2_header_convert_nv(&headers, hdrs),
|
|
|
|
headers.nvlen, h2_session);
|
|
|
|
headers.nvlen, h2_session);
|
|
|
|
if (stream_id < 0){
|
|
|
|
if (stream_id < 0){
|
|
|
|
printf("Fatal headers error: %s\n", nghttp2_strerror(stream_id));
|
|
|
|
printf("Fatal headers error: %s\n", nghttp2_strerror(stream_id));
|
|
|
|
@@ -1129,7 +1161,7 @@ upstream_create_req(struct tfe_h2_stream *h2_stream_info, nghttp2_session *as_se
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
|
|
|
|
|
|
|
|
half_set_callback(h2_session->req, event, NULL);
|
|
|
|
half_set_callback(h2_session->req, event, free);
|
|
|
|
|
|
|
|
|
|
|
|
/* Call business plugin */
|
|
|
|
/* Call business plugin */
|
|
|
|
half_private = h2_session->req;
|
|
|
|
half_private = h2_session->req;
|
|
|
|
@@ -1170,10 +1202,10 @@ nghttp2_server_frame_submit_push_promise(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
/* Create s' half req*/
|
|
|
|
/* Create s' half req*/
|
|
|
|
peer_h2_stream = (struct tfe_h2_session *)ALLOC(struct tfe_h2_session, 1);
|
|
|
|
peer_h2_stream = (struct tfe_h2_session *)ALLOC(struct tfe_h2_session, 1);
|
|
|
|
assert(peer_h2_stream);
|
|
|
|
assert(peer_h2_stream);
|
|
|
|
|
|
|
|
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
stream_id = nghttp2_submit_push_promise(h2_stream_info->as_server, headers->flag,
|
|
|
|
stream_id = nghttp2_submit_push_promise(h2_stream_info->as_server, headers->flag,
|
|
|
|
h2_session->ngh2_stream_id, nghttp2_nv_packet(headers, hdrs),
|
|
|
|
h2_session->ngh2_stream_id, tfe_h2_header_convert_nv(headers, hdrs),
|
|
|
|
headers->nvlen, peer_h2_stream);
|
|
|
|
headers->nvlen, peer_h2_stream);
|
|
|
|
if (stream_id < 0){
|
|
|
|
if (stream_id < 0){
|
|
|
|
free(peer_h2_stream);
|
|
|
|
free(peer_h2_stream);
|
|
|
|
@@ -1256,7 +1288,7 @@ suspend_start(struct tfe_h2_session *h2_session,
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
fill_resp_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|
|
|
fill_resp_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
struct tfe_h2_header *header = &half_private->header;
|
|
|
|
struct tfe_h2_header *header = &half_private->header;
|
|
|
|
struct tfe_http_resp_spec *resp_spec = &(half_private->half_public.resp_spec);
|
|
|
|
struct tfe_http_resp_spec *resp_spec = &(half_private->half_public.resp_spec);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1343,10 +1375,10 @@ nghttp2_server_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
headers = &resp->header;
|
|
|
|
headers = &resp->header;
|
|
|
|
if (headers->nvlen <= 0){
|
|
|
|
if (headers->nvlen <= 0){
|
|
|
|
return ACTION_FORWARD_DATA;
|
|
|
|
return ACTION_FORWARD_DATA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
xret = nghttp2_submit_headers(h2_stream_info->as_server, headers->flag,
|
|
|
|
xret = nghttp2_submit_headers(h2_stream_info->as_server, headers->flag,
|
|
|
|
h2_session->ngh2_stream_id, NULL, nghttp2_nv_packet(headers, hdrs),
|
|
|
|
h2_session->ngh2_stream_id, NULL, tfe_h2_header_convert_nv(headers, hdrs),
|
|
|
|
headers->nvlen, h2_session);
|
|
|
|
headers->nvlen, h2_session);
|
|
|
|
if (xret < 0){
|
|
|
|
if (xret < 0){
|
|
|
|
printf("Fatal headers error: %s\n", nghttp2_strerror(xret));
|
|
|
|
printf("Fatal headers error: %s\n", nghttp2_strerror(xret));
|
|
|
|
@@ -1410,7 +1442,7 @@ static void
|
|
|
|
fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|
|
|
fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int urllen = 0;
|
|
|
|
int urllen = 0;
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
|
|
|
|
struct tfe_h2_header *header = &half_private->header;
|
|
|
|
struct tfe_h2_header *header = &half_private->header;
|
|
|
|
struct tfe_http_req_spec *req_spec = &(half_private->half_public.req_spec);
|
|
|
|
struct tfe_http_req_spec *req_spec = &(half_private->half_public.req_spec);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1430,7 +1462,7 @@ fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char *urltmp = NULL;
|
|
|
|
char *urltmp = half_private->url_storage;
|
|
|
|
urltmp = (char *)malloc(urllen + 1);
|
|
|
|
urltmp = (char *)malloc(urllen + 1);
|
|
|
|
if(urltmp){
|
|
|
|
if(urltmp){
|
|
|
|
sprintf(urltmp, "%s%s", (char *)req_spec->host, (char *)req_spec->uri);
|
|
|
|
sprintf(urltmp, "%s%s", (char *)req_spec->host, (char *)req_spec->uri);
|
|
|
|
@@ -1461,10 +1493,10 @@ static enum tfe_stream_action
|
|
|
|
nghttp2_submit_built_response(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
nghttp2_submit_built_response(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
struct tfe_h2_session *h2_session)
|
|
|
|
struct tfe_h2_session *h2_session)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int xret = -1;
|
|
|
|
int xret = -1;
|
|
|
|
char value[128] = {0};
|
|
|
|
char value[128] = {0};
|
|
|
|
enum tfe_stream_action stream_action = ACTION_FORWARD_DATA;
|
|
|
|
enum tfe_stream_action stream_action = ACTION_FORWARD_DATA;
|
|
|
|
struct tfe_h2_half_private *resp = h2_session->plugin_built_resp;
|
|
|
|
struct tfe_h2_half_private *resp = h2_session->plugin_built_resp;
|
|
|
|
|
|
|
|
|
|
|
|
struct http_field_name field;
|
|
|
|
struct http_field_name field;
|
|
|
|
field.field_id = TFE_HTTP_UNKNOWN_FIELD;
|
|
|
|
field.field_id = TFE_HTTP_UNKNOWN_FIELD;
|
|
|
|
@@ -1509,7 +1541,7 @@ downstream_create_resp(struct tfe_h2_session *h2_session, nghttp2_session *as_cl
|
|
|
|
event->tf_stream = tf_stream;
|
|
|
|
event->tf_stream = tf_stream;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
|
|
|
|
|
|
|
|
half_set_callback(h2_session->resp, event, NULL);
|
|
|
|
half_set_callback(h2_session->resp, event, free);
|
|
|
|
|
|
|
|
|
|
|
|
h2_session->resp->frame_ctx = h2_session->frame_ctx;
|
|
|
|
h2_session->resp->frame_ctx = h2_session->frame_ctx;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1545,17 +1577,18 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
downstream_create_resp(h2_session, h2_stream_info->as_client, h2_stream_info->as_server,
|
|
|
|
downstream_create_resp(h2_session, h2_stream_info->as_client, h2_stream_info->as_server,
|
|
|
|
h2_stream_info->tf_stream, h2_stream_info->thread_id);
|
|
|
|
h2_stream_info->tf_stream, h2_stream_info->thread_id);
|
|
|
|
nghttp2_session_set_next_stream_id(h2_stream_info->as_client, h2_session->ngh2_stream_id);
|
|
|
|
nghttp2_session_set_next_stream_id(h2_stream_info->as_client, h2_session->ngh2_stream_id);
|
|
|
|
|
|
|
|
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
nghttp2_nv hdrs[headers->nvlen];
|
|
|
|
|
|
|
|
|
|
|
|
method = nghttp2_get_method(h2_session->req);
|
|
|
|
method = nghttp2_get_method(h2_session->req);
|
|
|
|
if (method == (enum tfe_http_std_method)NGHTTP2_METHOD_POST ||
|
|
|
|
if (method == (enum tfe_http_std_method)NGHTTP2_METHOD_POST ||
|
|
|
|
method == (enum tfe_http_std_method)NGHTTP2_METHOD_PUT){
|
|
|
|
method == (enum tfe_http_std_method)NGHTTP2_METHOD_PUT){
|
|
|
|
stream_id = nghttp2_submit_headers(h2_stream_info->as_client, headers->flag,
|
|
|
|
stream_id = nghttp2_submit_headers(h2_stream_info->as_client, headers->flag,
|
|
|
|
-1, NULL, nghttp2_nv_packet(headers, hdrs),
|
|
|
|
-1, NULL, tfe_h2_header_modify_field(headers, hdrs, ":path", req->url_storage),
|
|
|
|
headers->nvlen, h2_session);
|
|
|
|
headers->nvlen, h2_session);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
stream_id = nghttp2_submit_request(h2_stream_info->as_client, NULL,
|
|
|
|
stream_id = nghttp2_submit_request(h2_stream_info->as_client, NULL,
|
|
|
|
nghttp2_nv_packet(headers, hdrs),
|
|
|
|
tfe_h2_header_modify_field(headers, hdrs, ":path", req->url_storage),
|
|
|
|
headers->nvlen, NULL, h2_session);
|
|
|
|
headers->nvlen, NULL, h2_session);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stream_id < 0){
|
|
|
|
if (stream_id < 0){
|
|
|
|
@@ -1565,7 +1598,7 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
|
|
|
goto finish;
|
|
|
|
goto finish;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stream_action = ACTION_DROP_DATA;
|
|
|
|
stream_action = ACTION_DROP_DATA;
|
|
|
|
finish:
|
|
|
|
finish:
|
|
|
|
delete_nv_packet_data(headers);
|
|
|
|
delete_nv_packet_data(headers);
|
|
|
|
return stream_action;
|
|
|
|
return stream_action;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1661,7 +1694,7 @@ nghttp2_fill_up_header(nghttp2_session *ngh2_session, const nghttp2_frame *frame
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
struct tfe_h2_half_private *half = (dir == CONN_DIR_UPSTREAM) ? h2_session->resp : h2_session->req;
|
|
|
|
struct tfe_h2_half_private *half = (dir == CONN_DIR_UPSTREAM) ? h2_session->resp : h2_session->req;
|
|
|
|
|
|
|
|
|
|
|
|
struct http_field_name field;
|
|
|
|
struct http_field_name field;
|
|
|
|
field.field_id = (enum tfe_http_std_field)str_to_val((const char *)name, header_vals);
|
|
|
|
field.field_id = (enum tfe_http_std_field)str_to_val((const char *)name, header_vals);
|
|
|
|
if (field.field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
|
|
if (field.field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
|
|
@@ -1671,7 +1704,7 @@ nghttp2_fill_up_header(nghttp2_session *ngh2_session, const nghttp2_frame *frame
|
|
|
|
if (field.field_id == TFE_HTTP_CONT_ENCODING)
|
|
|
|
if (field.field_id == TFE_HTTP_CONT_ENCODING)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
half->body.gzip = method_to_str_idx((const char *)value);
|
|
|
|
half->body.gzip = method_to_str_idx((const char *)value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
h2_header = &half->header;
|
|
|
|
h2_header = &half->header;
|
|
|
|
tfe_h2_header_add_field(h2_header, &field, (const char *)value, 1);
|
|
|
|
tfe_h2_header_add_field(h2_header, &field, (const char *)value, 1);
|
|
|
|
h2_header->flag = frame->hd.flags;
|
|
|
|
h2_header->flag = frame->hd.flags;
|
|
|
|
@@ -1695,7 +1728,7 @@ nghttp2_fill_up_promise(nghttp2_session *ngh2_session, const nghttp2_frame *fram
|
|
|
|
frame->hd.stream_id);
|
|
|
|
frame->hd.stream_id);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp = h2_session->resp;
|
|
|
|
resp = h2_session->resp;
|
|
|
|
struct http_field_name field;
|
|
|
|
struct http_field_name field;
|
|
|
|
field.field_id = (enum tfe_http_std_field)str_to_val((const char *)name, header_vals);
|
|
|
|
field.field_id = (enum tfe_http_std_field)str_to_val((const char *)name, header_vals);
|
|
|
|
if (field.field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
|
|
if (field.field_id == TFE_HTTP_UNKNOWN_FIELD)
|
|
|
|
@@ -1705,7 +1738,7 @@ nghttp2_fill_up_promise(nghttp2_session *ngh2_session, const nghttp2_frame *fram
|
|
|
|
if (field.field_id == TFE_HTTP_CONT_ENCODING)
|
|
|
|
if (field.field_id == TFE_HTTP_CONT_ENCODING)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resp->body.gzip = method_to_str_idx((const char *)value);
|
|
|
|
resp->body.gzip = method_to_str_idx((const char *)value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
headers = &resp->promised;
|
|
|
|
headers = &resp->promised;
|
|
|
|
tfe_h2_header_add_field(headers, &field, (const char *)value, 1);
|
|
|
|
tfe_h2_header_add_field(headers, &field, (const char *)value, 1);
|
|
|
|
headers->flag = frame->hd.flags;
|
|
|
|
headers->flag = frame->hd.flags;
|
|
|
|
@@ -1865,6 +1898,7 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
|
|
|
resp->body.flags = flags;
|
|
|
|
resp->body.flags = flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uncompr_len) FREE(&uncompr);
|
|
|
|
|
|
|
|
|
|
|
|
stream_action = server_frame_submit_data(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
|
|
|
|
stream_action = server_frame_submit_data(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
|
|
|
|
if (stream_action == ACTION_DROP_DATA){
|
|
|
|
if (stream_action == ACTION_DROP_DATA){
|
|
|
|
@@ -1942,7 +1976,7 @@ create_upstream_data(nghttp2_session *session, int32_t stream_id,
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
|
|
|
|
|
|
|
|
half_set_callback(h2_session->resp, event, NULL);
|
|
|
|
half_set_callback(h2_session->resp, event, free);
|
|
|
|
|
|
|
|
|
|
|
|
h2_session->resp->frame_ctx = h2_session->frame_ctx;
|
|
|
|
h2_session->resp->frame_ctx = h2_session->frame_ctx;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2101,7 +2135,7 @@ create_serv_stream_data(nghttp2_session *session, int32_t stream_id,
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tf_stream = h2_stream_info->tf_stream;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
event->tfe_session = &h2_session->tfe_session;
|
|
|
|
|
|
|
|
|
|
|
|
half_set_callback(h2_session->req, event, NULL);
|
|
|
|
half_set_callback(h2_session->req, event, free);
|
|
|
|
|
|
|
|
|
|
|
|
/* Call business plugin */
|
|
|
|
/* Call business plugin */
|
|
|
|
half_private = h2_session->req;
|
|
|
|
half_private = h2_session->req;
|
|
|
|
@@ -2155,6 +2189,8 @@ nghttp2_server_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data = input;
|
|
|
|
data = input;
|
|
|
|
len = input_len;
|
|
|
|
len = input_len;
|
|
|
|
|
|
|
|
/*todo post data scan**/
|
|
|
|
|
|
|
|
if (uncompr_len) FREE(&uncompr);
|
|
|
|
|
|
|
|
|
|
|
|
stream_action = server_frame_submit_data(h2_stream_info, h2_session, CONN_DIR_DOWNSTREAM);
|
|
|
|
stream_action = server_frame_submit_data(h2_stream_info, h2_session, CONN_DIR_DOWNSTREAM);
|
|
|
|
if (stream_action == ACTION_DROP_DATA){
|
|
|
|
if (stream_action == ACTION_DROP_DATA){
|
|
|
|
|