diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp index 182b5d1..4808d2b 100644 --- a/plugin/protocol/http2/src/http2_stream.cpp +++ b/plugin/protocol/http2/src/http2_stream.cpp @@ -144,7 +144,7 @@ tfe_h2_header_modify_field(struct tfe_h2_header *header, nghttp2_nv *hdrs, const 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))) @@ -442,7 +442,7 @@ void delete_stream_half_data(struct tfe_h2_half_private **data, delete_nv_packet_data(&((*data)->header)); if (dir == CONN_DIR_DOWNSTREAM) - { + { struct tfe_http_req_spec *req_spec = &((*data)->half_public.req_spec); delete_http_req_spec(req_spec); } @@ -677,7 +677,7 @@ upstream_read_callback(nghttp2_session *session, int32_t stream_id, ssize_t datalen = 0, inputlen=0; struct tfe_h2_payload *to_send_body = (struct tfe_h2_payload *)source->ptr; - if (!to_send_body->evbuf_body || 0==(inputlen = evbuffer_get_length(to_send_body->evbuf_body)) + if (!to_send_body->evbuf_body || 0==(inputlen = evbuffer_get_length(to_send_body->evbuf_body)) ||!(input = evbuffer_pullup(to_send_body->evbuf_body, MIN(length, inputlen)))) { if ((to_send_body->flags & NGHTTP2_FLAG_END_STREAM) == 0) @@ -771,7 +771,7 @@ nghttp2_frame_submit_built_req(struct tfe_h2_stream *h2_stream_info, stream_id = nghttp2_submit_request(h2_stream_info->as_client, NULL, tfe_h2_header_modify_field(h2_header, hdrs, ":path", plugin_built_req->url_storage), h2_header->nvlen, &data_prd, h2_session); - + if (stream_id < 0){ TFE_LOG_ERROR(logger()->handle, "Could not submit request: %s", nghttp2_strerror(stream_id)); @@ -1138,12 +1138,12 @@ nghttp2_submit_complete_data(struct tfe_h2_stream *h2_stream_info, { int xret = -1; enum tfe_stream_action stream_action = ACTION_DROP_DATA; - - struct tfe_h2_half_private *h2_half = tfe_h2_stream_get_half(h2_session, dir); + + struct tfe_h2_half_private *h2_half = tfe_h2_stream_get_half(h2_session, dir); nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(h2_stream_info, dir); - - enum tfe_http_event http_body_event = (dir==CONN_DIR_UPSTREAM?EV_HTTP_RESP_BODY_END: EV_HTTP_REQ_BODY_END); + + enum tfe_http_event http_body_event = (dir==CONN_DIR_UPSTREAM?EV_HTTP_RESP_BODY_END: EV_HTTP_REQ_BODY_END); enum tfe_http_event http_event = (dir==CONN_DIR_UPSTREAM?EV_HTTP_RESP_END: EV_HTTP_REQ_END); if (h2_half->body_state != H2_READ_STATE_BEGIN) @@ -1644,7 +1644,11 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info, if (req == NULL){ return ACTION_FORWARD_DATA; } - + /*Create C' half_private_resp**/ + 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); + nghttp2_session_set_next_stream_id(h2_stream_info->as_client, h2_session->ngh2_stream_id); + if (h2_session->plugin_built_resp) { stream_action = nghttp2_submit_built_response(h2_stream_info, h2_session); @@ -1655,10 +1659,6 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info, { return ACTION_FORWARD_DATA; } - /*Create C' half_private_resp**/ - 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); - nghttp2_session_set_next_stream_id(h2_stream_info->as_client, h2_session->ngh2_stream_id); nghttp2_nv hdrs[headers->nvlen]; @@ -1666,7 +1666,7 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info, if (method == (enum tfe_http_std_method)NGHTTP2_METHOD_POST || method == (enum tfe_http_std_method)NGHTTP2_METHOD_PUT){ if (h2_session->plugin_built_req) - { + { stream_action = (enum tfe_stream_action)ACTION_USER_DATA; return stream_action; } @@ -1878,7 +1878,7 @@ nghttp2_on_stream_close(nghttp2_session *session, const nghttp2_frame *frame, co h2_stream_info->stream_action != ACTION_DEFER_DATA) nghttp2_submit_header_by_not_modify(h2_stream_info, h2_session); goto end; - } + } finish: TAILQ_REMOVE(&h2_stream_info->h2_session_list, h2_session, next); if (h2_session->frame_ctx){ @@ -2239,7 +2239,7 @@ create_serv_stream_data(nghttp2_session *session, int32_t stream_id, if (half_private->frame_ctx == NULL){ TFE_LOG_ERROR(logger()->handle, "Failed at raising session begin event. "); goto finish; - } + } h2_session->frame_ctx = half_private->frame_ctx; http_frame_raise_session_begin(half_private->frame_ctx, h2_stream_info->tf_stream, &h2_session->tfe_session, h2_stream_info->thread_id);