diff --git a/genheaderfunc.py b/genheaderfunc.py index f029ed17..98fa3f1c 100755 --- a/genheaderfunc.py +++ b/genheaderfunc.py @@ -54,22 +54,22 @@ enum {''' def gen_index_header(): print '''\ -void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { - switch (len) {''' +void index_header(int *hdidx, const uint8_t *name, size_t namelen, size_t idx) { + switch (namelen) {''' b = build_header(HEADERS) for size in sorted(b.keys()): ents = b[size] print '''\ case {}:'''.format(size) print '''\ - switch (util::lowcase(s[len - 1])) {''' + switch (util::lowcase(name[namelen - 1])) {''' for c in sorted(ents.keys()): headers = sorted(ents[c]) print '''\ case '{}':'''.format(c) for k in headers: print '''\ - if (util::strieq("{}", s, {})) {{ + if (util::streq("{}", name, {})) {{ hdidx[{}] = idx; return; }}'''.format(k[:-1], size - 1, to_enum_hd(k)) diff --git a/src/http2.cc b/src/http2.cc index 95ebc49f..bf800a51 100644 --- a/src/http2.cc +++ b/src/http2.cc @@ -576,12 +576,12 @@ void init_hdidx(int *hdidx) { memset(hdidx, -1, sizeof(hdidx[0]) * HD_MAXIDX); } // This function was generated by genheaderfunc.py. Inspired by h2o // header lookup. https://github.com/h2o/h2o -void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { - switch (len) { +void index_header(int *hdidx, const uint8_t *name, size_t namelen, size_t idx) { + switch (namelen) { case 2: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'e': - if (util::strieq("t", s, 1)) { + if (util::streq("t", name, 1)) { hdidx[HD_TE] = idx; return; } @@ -589,9 +589,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 4: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 't': - if (util::strieq("hos", s, 3)) { + if (util::streq("hos", name, 3)) { hdidx[HD_HOST] = idx; return; } @@ -599,9 +599,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 5: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'h': - if (util::strieq(":pat", s, 4)) { + if (util::streq(":pat", name, 4)) { hdidx[HD_PATH] = idx; return; } @@ -609,9 +609,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 6: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 't': - if (util::strieq("expec", s, 5)) { + if (util::streq("expec", name, 5)) { hdidx[HD_EXPECT] = idx; return; } @@ -619,19 +619,19 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 7: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'd': - if (util::strieq(":metho", s, 6)) { + if (util::streq(":metho", name, 6)) { hdidx[HD_METHOD] = idx; return; } break; case 'e': - if (util::strieq(":schem", s, 6)) { + if (util::streq(":schem", name, 6)) { hdidx[HD_SCHEME] = idx; return; } - if (util::strieq("upgrad", s, 6)) { + if (util::streq("upgrad", name, 6)) { hdidx[HD_UPGRADE] = idx; return; } @@ -639,21 +639,21 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 10: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'e': - if (util::strieq("keep-aliv", s, 9)) { + if (util::streq("keep-aliv", name, 9)) { hdidx[HD_KEEP_ALIVE] = idx; return; } break; case 'n': - if (util::strieq("connectio", s, 9)) { + if (util::streq("connectio", name, 9)) { hdidx[HD_CONNECTION] = idx; return; } break; case 'y': - if (util::strieq(":authorit", s, 9)) { + if (util::streq(":authorit", name, 9)) { hdidx[HD_AUTHORITY] = idx; return; } @@ -661,9 +661,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 16: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'n': - if (util::strieq("proxy-connectio", s, 15)) { + if (util::streq("proxy-connectio", name, 15)) { hdidx[HD_PROXY_CONNECTION] = idx; return; } @@ -671,15 +671,15 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { } break; case 17: - switch (util::lowcase(s[len - 1])) { + switch (util::lowcase(name[namelen - 1])) { case 'e': - if (util::strieq("if-modified-sinc", s, 16)) { + if (util::streq("if-modified-sinc", name, 16)) { hdidx[HD_IF_MODIFIED_SINCE] = idx; return; } break; case 'g': - if (util::strieq("transfer-encodin", s, 16)) { + if (util::streq("transfer-encodin", name, 16)) { hdidx[HD_TRANSFER_ENCODING] = idx; return; } @@ -695,7 +695,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s, case 5: switch (util::lowcase(s[len - 1])) { case 'h': - if (util::strieq(":pat", s, 4)) { + if (util::streq(":pat", s, 4)) { if (hdidx[HD_PATH] != -1) { return false; } @@ -707,7 +707,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s, case 7: switch (util::lowcase(s[len - 1])) { case 'd': - if (util::strieq(":metho", s, 6)) { + if (util::streq(":metho", s, 6)) { if (hdidx[HD_METHOD] != -1) { return false; } @@ -715,7 +715,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s, } break; case 'e': - if (util::strieq(":schem", s, 6)) { + if (util::streq(":schem", s, 6)) { if (hdidx[HD_SCHEME] != -1) { return false; } @@ -727,7 +727,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s, case 10: switch (util::lowcase(s[len - 1])) { case 'y': - if (util::strieq(":authorit", s, 9)) { + if (util::streq(":authorit", s, 9)) { if (hdidx[HD_AUTHORITY] != -1) { return false; }