summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2019-07-02 22:20:12 +0800
committerfengweihao <[email protected]>2019-07-02 22:20:12 +0800
commitc3741ed8c0f4be776409671d424fbbb6a03a2ce4 (patch)
tree52415e16c5e5747937a5e78cdf49a706d9fa87da
parent348afbc00d76c5ebc877c5067b30903fadd9ee3d (diff)
修复从服务端控制帧判断http2流字节数限制v4.0.6-20190702
-rw-r--r--plugin/protocol/http2/src/http2_plugin.cpp22
-rw-r--r--plugin/protocol/http2/src/http2_stream.cpp20
2 files changed, 19 insertions, 23 deletions
diff --git a/plugin/protocol/http2/src/http2_plugin.cpp b/plugin/protocol/http2/src/http2_plugin.cpp
index 3f1c30f..9dc41ce 100644
--- a/plugin/protocol/http2/src/http2_plugin.cpp
+++ b/plugin/protocol/http2/src/http2_plugin.cpp
@@ -35,7 +35,7 @@ static const uint8_t kMagicHello[] = {
#define TFE_BASIC_CFG "conf/tfe/tfe.conf"
#define MAGIC_FRAME_LENGTH 24
-#define SET_FRAME_LENGTH 18
+#define SET_FRAME_LENGTH 9
struct event_timer_ctx
{
@@ -120,25 +120,21 @@ http2_stream_open(const struct tfe_stream *stream, unsigned int thread_id,
return 0;
}
-/*setting frame: 00 00 12 04 00 00 00 00 00 00 03 00 00 00 80 00 04 7f ff ff ff 00 05 00 ff ff ff 00 00 04 08 00
-00 00 00 00 7f ff 00 00 ***/
+/*setting frame: 00 00 06 04 00 00 00 00 00 00 04**/
static int
search_up_stream_data(const unsigned char * data, size_t len)
{
uint8_t indetifier = 0;
- if (get_u_int8_t(data, 3) != 0x4)
+ if ((get_u_int8_t(data, 3) != 0x4) && (get_u_int8_t(data, 4) != 0) && (get_u_int8_t(data, 9) != 0))
+ {
return 0;
-
+ }
indetifier = get_u_int8_t(data, 10);
- if (indetifier < NGHTTP2_SETTINGS_HEADER_TABLE_SIZE ||
- indetifier > NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE)
- return 0;
-
- indetifier = get_u_int8_t(data, 16);
- if (indetifier < NGHTTP2_SETTINGS_HEADER_TABLE_SIZE ||
- indetifier > NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE)
+ if (indetifier < NGHTTP2_SETTINGS_HEADER_TABLE_SIZE || indetifier > NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE)
+ {
return 0;
+ }
return 1;
}
@@ -160,7 +156,7 @@ http2_stream_data(const struct tfe_stream * stream, unsigned int thread_id,
}
if (search_up_stream_data(data, len)){
}else{
- goto finish;
+ goto detach;
}
}
if (dir == CONN_DIR_DOWNSTREAM){
diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp
index 907a8e8..878d466 100644
--- a/plugin/protocol/http2/src/http2_stream.cpp
+++ b/plugin/protocol/http2/src/http2_stream.cpp
@@ -1650,8 +1650,7 @@ finish:
return 0;
}
-static void
-fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
+static int fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
{
int urllen = 0;
struct tfe_h2_field *h2_field = NULL, *peer_h2_field = NULL;
@@ -1678,9 +1677,10 @@ fill_req_spec_from_handle(struct tfe_h2_half_private *half_private)
if(urltmp){
sprintf(urltmp, "%s%s", (char *)req_spec->host, (char *)req_spec->uri);
req_spec->url = urltmp;
+ if (strcasestr(urltmp, "twitter"))
+ return 1;
}
-
- return;
+ return 0;
}
#ifdef TFE_CACHE
@@ -1728,7 +1728,7 @@ finish:
static enum tfe_stream_action
nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
- struct tfe_h2_session *h2_session)
+ struct tfe_h2_session *h2_session, int twitter)
{
int32_t stream_id = -1;
struct tfe_h2_header *headers = NULL;
@@ -1760,8 +1760,8 @@ nghttp2_client_frame_submit_header(struct tfe_h2_stream *h2_stream_info,
nghttp2_nv hdrs[headers->nvlen];
method = nghttp2_get_method(h2_session->req);
- if (method == (enum tfe_http_std_method)NGHTTP2_METHOD_POST ||
- method == (enum tfe_http_std_method)NGHTTP2_METHOD_PUT){
+ if ((method == (enum tfe_http_std_method)NGHTTP2_METHOD_POST ||
+ method == (enum tfe_http_std_method)NGHTTP2_METHOD_PUT) && twitter != 1){
if (h2_session->plugin_built_req)
{
stream_action = (enum tfe_stream_action)ACTION_USER_DATA;
@@ -1790,7 +1790,7 @@ finish:
static int
nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t stream_id)
{
- int xret = -1;
+ int xret = -1, twitter = 1;
struct tfe_h2_half_private *req = NULL;
struct tfe_h2_session *h2_session = NULL;
@@ -1805,12 +1805,12 @@ nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t strea
assert(h2_session->ngh2_stream_id == stream_id);
req = h2_session->req;
- fill_req_spec_from_handle(h2_session->req);
+ twitter = fill_req_spec_from_handle(h2_session->req);
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);
- stream_action = nghttp2_client_frame_submit_header(h2_stream_info, h2_session);
+ stream_action = nghttp2_client_frame_submit_header(h2_stream_info, h2_session, twitter);
if (stream_action == ACTION_DROP_DATA){
xret = nghttp2_session_send(h2_stream_info->as_client);
if (xret != 0) {