src: Only index header in lowercase

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-03 21:56:59 +09:00
parent 9763ea768d
commit ea0ab938c4
2 changed files with 31 additions and 31 deletions

View File

@ -54,22 +54,22 @@ enum {'''
def gen_index_header(): def gen_index_header():
print '''\ print '''\
void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { void index_header(int *hdidx, const uint8_t *name, size_t namelen, size_t idx) {
switch (len) {''' switch (namelen) {'''
b = build_header(HEADERS) b = build_header(HEADERS)
for size in sorted(b.keys()): for size in sorted(b.keys()):
ents = b[size] ents = b[size]
print '''\ print '''\
case {}:'''.format(size) case {}:'''.format(size)
print '''\ print '''\
switch (util::lowcase(s[len - 1])) {''' switch (util::lowcase(name[namelen - 1])) {'''
for c in sorted(ents.keys()): for c in sorted(ents.keys()):
headers = sorted(ents[c]) headers = sorted(ents[c])
print '''\ print '''\
case '{}':'''.format(c) case '{}':'''.format(c)
for k in headers: for k in headers:
print '''\ print '''\
if (util::strieq("{}", s, {})) {{ if (util::streq("{}", name, {})) {{
hdidx[{}] = idx; hdidx[{}] = idx;
return; return;
}}'''.format(k[:-1], size - 1, to_enum_hd(k)) }}'''.format(k[:-1], size - 1, to_enum_hd(k))

View File

@ -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 // This function was generated by genheaderfunc.py. Inspired by h2o
// header lookup. https://github.com/h2o/h2o // header lookup. https://github.com/h2o/h2o
void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) { void index_header(int *hdidx, const uint8_t *name, size_t namelen, size_t idx) {
switch (len) { switch (namelen) {
case 2: case 2:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'e': case 'e':
if (util::strieq("t", s, 1)) { if (util::streq("t", name, 1)) {
hdidx[HD_TE] = idx; hdidx[HD_TE] = idx;
return; return;
} }
@ -589,9 +589,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 4: case 4:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 't': case 't':
if (util::strieq("hos", s, 3)) { if (util::streq("hos", name, 3)) {
hdidx[HD_HOST] = idx; hdidx[HD_HOST] = idx;
return; return;
} }
@ -599,9 +599,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 5: case 5:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'h': case 'h':
if (util::strieq(":pat", s, 4)) { if (util::streq(":pat", name, 4)) {
hdidx[HD_PATH] = idx; hdidx[HD_PATH] = idx;
return; return;
} }
@ -609,9 +609,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 6: case 6:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 't': case 't':
if (util::strieq("expec", s, 5)) { if (util::streq("expec", name, 5)) {
hdidx[HD_EXPECT] = idx; hdidx[HD_EXPECT] = idx;
return; return;
} }
@ -619,19 +619,19 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 7: case 7:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'd': case 'd':
if (util::strieq(":metho", s, 6)) { if (util::streq(":metho", name, 6)) {
hdidx[HD_METHOD] = idx; hdidx[HD_METHOD] = idx;
return; return;
} }
break; break;
case 'e': case 'e':
if (util::strieq(":schem", s, 6)) { if (util::streq(":schem", name, 6)) {
hdidx[HD_SCHEME] = idx; hdidx[HD_SCHEME] = idx;
return; return;
} }
if (util::strieq("upgrad", s, 6)) { if (util::streq("upgrad", name, 6)) {
hdidx[HD_UPGRADE] = idx; hdidx[HD_UPGRADE] = idx;
return; return;
} }
@ -639,21 +639,21 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 10: case 10:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'e': case 'e':
if (util::strieq("keep-aliv", s, 9)) { if (util::streq("keep-aliv", name, 9)) {
hdidx[HD_KEEP_ALIVE] = idx; hdidx[HD_KEEP_ALIVE] = idx;
return; return;
} }
break; break;
case 'n': case 'n':
if (util::strieq("connectio", s, 9)) { if (util::streq("connectio", name, 9)) {
hdidx[HD_CONNECTION] = idx; hdidx[HD_CONNECTION] = idx;
return; return;
} }
break; break;
case 'y': case 'y':
if (util::strieq(":authorit", s, 9)) { if (util::streq(":authorit", name, 9)) {
hdidx[HD_AUTHORITY] = idx; hdidx[HD_AUTHORITY] = idx;
return; return;
} }
@ -661,9 +661,9 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 16: case 16:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'n': case 'n':
if (util::strieq("proxy-connectio", s, 15)) { if (util::streq("proxy-connectio", name, 15)) {
hdidx[HD_PROXY_CONNECTION] = idx; hdidx[HD_PROXY_CONNECTION] = idx;
return; return;
} }
@ -671,15 +671,15 @@ void index_header(int *hdidx, const uint8_t *s, size_t len, size_t idx) {
} }
break; break;
case 17: case 17:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(name[namelen - 1])) {
case 'e': case 'e':
if (util::strieq("if-modified-sinc", s, 16)) { if (util::streq("if-modified-sinc", name, 16)) {
hdidx[HD_IF_MODIFIED_SINCE] = idx; hdidx[HD_IF_MODIFIED_SINCE] = idx;
return; return;
} }
break; break;
case 'g': case 'g':
if (util::strieq("transfer-encodin", s, 16)) { if (util::streq("transfer-encodin", name, 16)) {
hdidx[HD_TRANSFER_ENCODING] = idx; hdidx[HD_TRANSFER_ENCODING] = idx;
return; return;
} }
@ -695,7 +695,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s,
case 5: case 5:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(s[len - 1])) {
case 'h': case 'h':
if (util::strieq(":pat", s, 4)) { if (util::streq(":pat", s, 4)) {
if (hdidx[HD_PATH] != -1) { if (hdidx[HD_PATH] != -1) {
return false; return false;
} }
@ -707,7 +707,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s,
case 7: case 7:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(s[len - 1])) {
case 'd': case 'd':
if (util::strieq(":metho", s, 6)) { if (util::streq(":metho", s, 6)) {
if (hdidx[HD_METHOD] != -1) { if (hdidx[HD_METHOD] != -1) {
return false; return false;
} }
@ -715,7 +715,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s,
} }
break; break;
case 'e': case 'e':
if (util::strieq(":schem", s, 6)) { if (util::streq(":schem", s, 6)) {
if (hdidx[HD_SCHEME] != -1) { if (hdidx[HD_SCHEME] != -1) {
return false; return false;
} }
@ -727,7 +727,7 @@ bool check_http2_request_pseudo_header(int *hdidx, const uint8_t *s,
case 10: case 10:
switch (util::lowcase(s[len - 1])) { switch (util::lowcase(s[len - 1])) {
case 'y': case 'y':
if (util::strieq(":authorit", s, 9)) { if (util::streq(":authorit", s, 9)) {
if (hdidx[HD_AUTHORITY] != -1) { if (hdidx[HD_AUTHORITY] != -1) {
return false; return false;
} }