修复twitter页面无法显示问题,原因为注册END_STREAM时传参错误,导致获取取half值时方向错误
http2注册请求头时,不在区分post/get
This commit is contained in:
@@ -1411,13 +1411,11 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
|
|||||||
rewrite_buff = NULL;
|
rewrite_buff = NULL;
|
||||||
rewrite_sz = 0;
|
rewrite_sz = 0;
|
||||||
|
|
||||||
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
|
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
|
||||||
&& (strstr(in_resp_spec->content_type, "charset=utf-8") ||
|
&& strcasestr(in_resp_spec->content_type, "charset=utf-8"))
|
||||||
(strstr(in_resp_spec->content_type, "charset=UTF-8"))))
|
|
||||||
{
|
{
|
||||||
options = 1;
|
options = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewrite_sz = execute_replace_rule(__http_body, __http_body_len, r_zone,
|
rewrite_sz = execute_replace_rule(__http_body, __http_body_len, r_zone,
|
||||||
rep_ctx->rule, rep_ctx->n_rule, &rewrite_buff, options);
|
rep_ctx->rule, rep_ctx->n_rule, &rewrite_buff, options);
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ tfe_h2_header_modify_field(struct tfe_h2_header *header, nghttp2_nv *hdrs, const
|
|||||||
{
|
{
|
||||||
hdrs[nvlen].value = h2_field->nv.value;
|
hdrs[nvlen].value = h2_field->nv.value;
|
||||||
hdrs[nvlen].valuelen = h2_field->nv.valuelen;
|
hdrs[nvlen].valuelen = h2_field->nv.valuelen;
|
||||||
}
|
}
|
||||||
hdrs[nvlen].flags = h2_field->nv.flags;
|
hdrs[nvlen].flags = h2_field->nv.flags;
|
||||||
nvlen++;
|
nvlen++;
|
||||||
}
|
}
|
||||||
@@ -864,9 +864,9 @@ nghttp2_submit_data_by_h2_half(struct tfe_h2_stream *connection,
|
|||||||
struct tfe_h2_session *h2_session,
|
struct tfe_h2_session *h2_session,
|
||||||
enum tfe_conn_dir dir)
|
enum tfe_conn_dir dir)
|
||||||
{
|
{
|
||||||
enum tfe_stream_action stream_action = ACTION_DROP_DATA;
|
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 = (dir == CONN_DIR_UPSTREAM) ? h2_session->resp : h2_session->req;
|
|
||||||
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
|
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
|
||||||
|
|
||||||
if (h2_session->plugin_built_resp)
|
if (h2_session->plugin_built_resp)
|
||||||
@@ -1239,7 +1239,7 @@ nghttp2_submit_complete_data(struct tfe_h2_stream *h2_stream_info,
|
|||||||
h2_half->body_state = H2_READ_STATE_COMPLETE;
|
h2_half->body_state = H2_READ_STATE_COMPLETE;
|
||||||
h2_half->message_state = H2_READ_STATE_COMPLETE;
|
h2_half->message_state = H2_READ_STATE_COMPLETE;
|
||||||
|
|
||||||
stream_action = nghttp2_submit_data_by_h2_half(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
|
stream_action = nghttp2_submit_data_by_h2_half(h2_stream_info, h2_session, dir);
|
||||||
if (stream_action == ACTION_DROP_DATA){
|
if (stream_action == ACTION_DROP_DATA){
|
||||||
xret = nghttp2_session_send(ngh2_session);
|
xret = nghttp2_session_send(ngh2_session);
|
||||||
if (xret != 0) {
|
if (xret != 0) {
|
||||||
@@ -1650,7 +1650,7 @@ finish:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
|
static void 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;
|
||||||
@@ -1677,10 +1677,8 @@ static int fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
|
|||||||
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);
|
||||||
req_spec->url = urltmp;
|
req_spec->url = urltmp;
|
||||||
if (strcasestr(urltmp, "twitter"))
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TFE_CACHE
|
#ifdef TFE_CACHE
|
||||||
@@ -1728,7 +1726,7 @@ finish:
|
|||||||
|
|
||||||
static enum tfe_stream_action
|
static enum tfe_stream_action
|
||||||
nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
||||||
struct tfe_h2_session *h2_session, int twitter)
|
struct tfe_h2_session *h2_session)
|
||||||
{
|
{
|
||||||
int32_t stream_id = -1;
|
int32_t stream_id = -1;
|
||||||
struct tfe_h2_header *headers = NULL;
|
struct tfe_h2_header *headers = NULL;
|
||||||
@@ -1757,24 +1755,19 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
|
|||||||
return ACTION_FORWARD_DATA;
|
return ACTION_FORWARD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) && twitter != 1){
|
{
|
||||||
if (h2_session->plugin_built_req)
|
if (h2_session->plugin_built_req != NULL)
|
||||||
{
|
{
|
||||||
stream_action = (enum tfe_stream_action)ACTION_USER_DATA;
|
stream_action = (enum tfe_stream_action)ACTION_USER_DATA;
|
||||||
return stream_action;
|
return stream_action;
|
||||||
}
|
}
|
||||||
stream_id = nghttp2_submit_headers(h2_stream_info->as_client, headers->flag,
|
}
|
||||||
-1, NULL, tfe_h2_header_modify_field(headers, hdrs, ":path", req->url_storage),
|
nghttp2_nv hdrs[headers->nvlen];
|
||||||
headers->nvlen, h2_session);
|
stream_id = nghttp2_submit_headers(h2_stream_info->as_client, headers->flag,
|
||||||
}else{
|
-1, NULL, tfe_h2_header_modify_field(headers, hdrs, ":path", req->url_storage),
|
||||||
stream_id = nghttp2_submit_request(h2_stream_info->as_client, NULL,
|
headers->nvlen, h2_session);
|
||||||
tfe_h2_header_modify_field(headers, hdrs, ":path", req->url_storage),
|
|
||||||
headers->nvlen, NULL, h2_session);
|
|
||||||
}
|
|
||||||
if (stream_id < 0){
|
if (stream_id < 0){
|
||||||
TFE_LOG_ERROR(logger()->handle, "Could not submit request: %s",
|
TFE_LOG_ERROR(logger()->handle, "Could not submit request: %s",
|
||||||
nghttp2_strerror(stream_id));
|
nghttp2_strerror(stream_id));
|
||||||
@@ -1790,7 +1783,7 @@ finish:
|
|||||||
static int
|
static int
|
||||||
nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t stream_id)
|
nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t stream_id)
|
||||||
{
|
{
|
||||||
int xret = -1, twitter = 1;
|
int xret = -1;
|
||||||
struct tfe_h2_half_private *req = NULL;
|
struct tfe_h2_half_private *req = NULL;
|
||||||
struct tfe_h2_session *h2_session = NULL;
|
struct tfe_h2_session *h2_session = NULL;
|
||||||
|
|
||||||
@@ -1805,12 +1798,12 @@ nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t strea
|
|||||||
assert(h2_session->ngh2_stream_id == stream_id);
|
assert(h2_session->ngh2_stream_id == stream_id);
|
||||||
|
|
||||||
req = h2_session->req;
|
req = h2_session->req;
|
||||||
twitter = fill_req_spec_from_handle(h2_session->req);
|
fill_req_spec_from_handle(h2_session->req);
|
||||||
|
|
||||||
req->event_cb(req, EV_HTTP_REQ_HDR, NULL, 0, req->event_cb_user);
|
req->event_cb(req, EV_HTTP_REQ_HDR, NULL, 0, req->event_cb_user);
|
||||||
|
|
||||||
nghttp2_write_log(h2_session, h2_stream_info->tf_stream->str_stream_info, CONN_DIR_DOWNSTREAM);
|
nghttp2_write_log(h2_session, h2_stream_info->tf_stream->str_stream_info, CONN_DIR_DOWNSTREAM);
|
||||||
stream_action = nghttp2_client_frame_submit_header(h2_stream_info, h2_session, twitter);
|
stream_action = nghttp2_client_frame_submit_header(h2_stream_info, h2_session);
|
||||||
if (stream_action == ACTION_DROP_DATA){
|
if (stream_action == ACTION_DROP_DATA){
|
||||||
xret = nghttp2_session_send(h2_stream_info->as_client);
|
xret = nghttp2_session_send(h2_stream_info->as_client);
|
||||||
if (xret != 0) {
|
if (xret != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user