1.修复chello为空导致访问越界
2.修复twitter字符编码为charset=“utf-8”,原判断可能存在问题 3.修复http2页面替换,由于存在use_half,而无数据域,造成页面卡顿 4.修复http2替换时,由于解码失败,造成页面无法发送
This commit is contained in:
@@ -266,7 +266,8 @@ void ssl_service_cache_write(struct ssl_service_cache* svc_cache, const struct s
|
||||
long cli_st_cb_ret=0, svr_st_cb_ret=0;
|
||||
char hash_key[2048];
|
||||
size_t hash_key_sz=0;
|
||||
if(chello->sni==NULL)
|
||||
|
||||
if(chello == NULL || chello->sni==NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1412,7 +1412,7 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
|
||||
rewrite_sz = 0;
|
||||
|
||||
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
|
||||
&& strcasestr(in_resp_spec->content_type, "charset=utf-8"))
|
||||
&& strcasestr(in_resp_spec->content_type, "utf-8"))
|
||||
{
|
||||
options = 1;
|
||||
}
|
||||
|
||||
@@ -753,11 +753,13 @@ nghttp2_frame_submit_built_resp(struct tfe_h2_stream *h2_stream_info,
|
||||
{
|
||||
int rv = -1;
|
||||
struct tfe_h2_header *h2_header = NULL;
|
||||
struct tfe_h2_half_private *pangu_resp = NULL;
|
||||
struct tfe_h2_half_private *pangu_resp = NULL, *resp = NULL;
|
||||
|
||||
resp = h2_session->resp;
|
||||
pangu_resp = h2_session->plugin_built_resp;
|
||||
|
||||
if (pangu_resp->message_state != H2_READ_STATE_COMPLETE){
|
||||
if (pangu_resp->message_state != H2_READ_STATE_COMPLETE && (evbuffer_get_length(resp->h2_payload.evbuf_body) > 0))
|
||||
{
|
||||
return (enum tfe_stream_action)ACTION_USER_DATA;
|
||||
}
|
||||
h2_header = &pangu_resp->header;
|
||||
@@ -861,6 +863,32 @@ nghttp2_submit_end_data_by_h2_half(struct tfe_h2_stream *h2_stream_info, int32_t
|
||||
return;
|
||||
}
|
||||
|
||||
static enum tfe_stream_action
|
||||
nghttp2_submit_data_by_user(struct tfe_h2_stream *connection,
|
||||
struct tfe_h2_session *h2_session,
|
||||
enum tfe_conn_dir dir)
|
||||
{
|
||||
int rv = -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);
|
||||
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
|
||||
|
||||
struct tfe_h2_payload *body = &h2_half->h2_payload;
|
||||
|
||||
nghttp2_data_provider upstream_data_provider;
|
||||
upstream_data_provider.source.ptr = (void *)body;
|
||||
upstream_data_provider.read_callback = upstream_read_callback;
|
||||
|
||||
rv = nghttp2_submit_data(ngh2_session, body->flags,
|
||||
h2_session->ngh2_stream_id, &upstream_data_provider);
|
||||
if (rv != 0){
|
||||
stream_action = ACTION_FORWARD_DATA;
|
||||
//printf("Fatal server submit data error: %s\n", nghttp2_strerror(rv));
|
||||
}
|
||||
return stream_action;
|
||||
}
|
||||
|
||||
static enum tfe_stream_action
|
||||
nghttp2_submit_data_by_h2_half(struct tfe_h2_stream *connection,
|
||||
struct tfe_h2_session *h2_session,
|
||||
@@ -890,7 +918,8 @@ nghttp2_submit_data_by_h2_half(struct tfe_h2_stream *connection,
|
||||
|
||||
rv = nghttp2_submit_data(ngh2_session, body->flags,
|
||||
h2_session->ngh2_stream_id, &upstream_data_provider);
|
||||
if (rv != 0){
|
||||
if (rv != 0)
|
||||
{
|
||||
stream_action = ACTION_FORWARD_DATA;
|
||||
//printf("Fatal server submit data error: %s\n", nghttp2_strerror(rv));
|
||||
}
|
||||
@@ -1228,11 +1257,13 @@ nghttp2_submit_complete_data(struct tfe_h2_stream *h2_stream_info,
|
||||
|
||||
if (h2_half->body_state != H2_READ_STATE_BEGIN)
|
||||
{
|
||||
if (h2_half->event_cb) {
|
||||
if (h2_half->event_cb)
|
||||
{
|
||||
h2_half->event_cb(h2_half, http_body_event, NULL, 0,
|
||||
h2_half->event_cb_user);
|
||||
}
|
||||
if (h2_half->event_cb) {
|
||||
if (h2_half->event_cb)
|
||||
{
|
||||
h2_half->event_cb(h2_half, http_event, NULL, 0,
|
||||
h2_half->event_cb_user);
|
||||
}
|
||||
@@ -1243,9 +1274,11 @@ nghttp2_submit_complete_data(struct tfe_h2_stream *h2_stream_info,
|
||||
h2_half->message_state = H2_READ_STATE_COMPLETE;
|
||||
|
||||
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);
|
||||
if (xret != 0) {
|
||||
if (xret != 0)
|
||||
{
|
||||
stream_action = ACTION_FORWARD_DATA;
|
||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s %d\n",nghttp2_strerror(xret), __LINE__);
|
||||
}
|
||||
@@ -2054,51 +2087,73 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
||||
h2_stream_info->stream_action = ACTION_DROP_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
evbuffer_add(resp->h2_payload.evbuf_body, input, input_len);
|
||||
if (resp->h2_payload.gzip != HTTP2_CONTENT_ENCODING_NONE){
|
||||
if (resp->h2_payload.gzip != HTTP2_CONTENT_ENCODING_NONE)
|
||||
{
|
||||
ret = inflate_read(input, input_len, &uncompr, &uncompr_len,
|
||||
&resp->h2_payload.inflate, resp->h2_payload.gzip);
|
||||
if (((ret == Z_STREAM_END) || (ret == Z_OK)) && uncompr > 0){
|
||||
if (((ret == Z_STREAM_END) || (ret == Z_OK)) && uncompr_len > 0)
|
||||
{
|
||||
input = (const uint8_t*)uncompr;
|
||||
input_len = uncompr_len;
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uncompr_len) FREE(&uncompr);
|
||||
stream_action = nghttp2_submit_data_by_user(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
|
||||
if (stream_action == ACTION_DROP_DATA)
|
||||
{
|
||||
xret = nghttp2_session_send(h2_stream_info->as_server);
|
||||
if (xret != 0)
|
||||
{
|
||||
stream_action = ACTION_FORWARD_DATA;
|
||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream(%d) send error: %s\n",stream_id, nghttp2_strerror(xret));
|
||||
}
|
||||
}
|
||||
h2_stream_info->stream_action = stream_action;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
data = input;
|
||||
len = input_len;
|
||||
|
||||
if (resp->body_state == H2_READ_STATE_BEGIN){
|
||||
if (resp->event_cb) {
|
||||
if (resp->body_state == H2_READ_STATE_BEGIN)
|
||||
{
|
||||
if (resp->event_cb)
|
||||
{
|
||||
resp->event_cb(resp, EV_HTTP_RESP_BODY_BEGIN, NULL, len,
|
||||
resp->event_cb_user);
|
||||
}
|
||||
if (flags == NGHTTP2_FLAG_END_STREAM){
|
||||
if (flags == NGHTTP2_FLAG_END_STREAM)
|
||||
{
|
||||
resp->h2_payload.flags = NGHTTP2_FLAG_NONE;
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
resp->h2_payload.flags = flags;
|
||||
}
|
||||
resp->body_state = H2_READ_STATE_READING;
|
||||
}
|
||||
if (resp->body_state == H2_READ_STATE_READING){
|
||||
if (resp->event_cb) {
|
||||
if (resp->body_state == H2_READ_STATE_READING)
|
||||
{
|
||||
if (resp->event_cb)
|
||||
{
|
||||
resp->event_cb(resp, EV_HTTP_RESP_BODY_CONT, data, len,
|
||||
resp->event_cb_user);
|
||||
}
|
||||
if (flags == NGHTTP2_FLAG_END_STREAM){
|
||||
if (flags == NGHTTP2_FLAG_END_STREAM)
|
||||
{
|
||||
resp->h2_payload.flags = NGHTTP2_FLAG_NONE;
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
resp->h2_payload.flags = flags;
|
||||
}
|
||||
}
|
||||
if (uncompr_len) FREE(&uncompr);
|
||||
|
||||
stream_action = nghttp2_submit_data_by_h2_half(h2_stream_info, h2_session, CONN_DIR_UPSTREAM);
|
||||
if (stream_action == ACTION_DROP_DATA){
|
||||
if (stream_action == ACTION_DROP_DATA)
|
||||
{
|
||||
xret = nghttp2_session_send(h2_stream_info->as_server);
|
||||
if (xret != 0) {
|
||||
if (xret != 0)
|
||||
{
|
||||
stream_action = ACTION_FORWARD_DATA;
|
||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream(%d) send error: %s\n",stream_id, nghttp2_strerror(xret));
|
||||
}
|
||||
@@ -2490,6 +2545,8 @@ server_session_init(struct tfe_h2_stream *h2_stream_info)
|
||||
|
||||
nghttp2_session_server_new(&h2_stream_info->as_server, callbacks, h2_stream_info);
|
||||
|
||||
h2_stream_info->as_server->opt_flags |= NGHTTP2_OPTMASK_NO_CLOSED_STREAMS;
|
||||
|
||||
nghttp2_session_callbacks_del(callbacks);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user