Skip to content

Commit 570fe76

Browse files
committed
A field name is really a token
1 parent 7a78a91 commit 570fe76

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/HttpParser.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ struct HttpParser {
217217
return unsignedIntegerValue;
218218
}
219219

220-
/* RFC 9110 16.3.1 Field Name Registry (TLDR; alnum + hyphen is allowed)
221-
* [...] It MUST conform to the field-name syntax defined in Section 5.1,
222-
* and it SHOULD be restricted to just letters, digits,
223-
* and hyphen ('-') characters, with the first character being a letter. */
224-
static inline bool isFieldNameByte(unsigned char x) {
225-
return (x == '-') |
226-
((x > '/') & (x < ':')) |
227-
((x > '@') & (x < '[')) |
228-
((x > 96) & (x < '{'));
220+
/* RFC 9110 5.6.2. Tokens */
221+
static inline bool isFieldNameByte(unsigned char c)
222+
{
223+
return (c > 32) & (c < 127) & (c != '(') &
224+
(c != ')') & (c != ',') & (c != '/') &
225+
(c != ':') & (c != ';') & (c != '<') &
226+
(c != '=') & (c != '>') & (c != '?') &
227+
(c != '@') & (c != '[') & (c != '\\') &
228+
(c != ']') & (c != '{') & (c != '}');
229229
}
230230

231231
static inline uint64_t hasLess(uint64_t x, uint64_t n) {
@@ -249,18 +249,18 @@ struct HttpParser {
249249
}
250250

251251
static inline void *consumeFieldName(char *p) {
252-
for (; true; p += 8) {
253-
uint64_t word;
254-
memcpy(&word, p, sizeof(uint64_t));
255-
if (notFieldNameWord(word)) {
252+
//for (; true; p += 8) {
253+
//uint64_t word;
254+
//memcpy(&word, p, sizeof(uint64_t));
255+
//if (notFieldNameWord(word)) {
256256
while (isFieldNameByte(*(unsigned char *)p)) {
257257
*(p++) |= 0x20;
258258
}
259259
return (void *)p;
260-
}
261-
word |= 0x2020202020202020ull;
262-
memcpy(p, &word, sizeof(uint64_t));
263-
}
260+
//}
261+
//word |= 0x2020202020202020ull;
262+
//memcpy(p, &word, sizeof(uint64_t));
263+
//}
264264
}
265265

266266
/* Puts method as key, target as value and returns non-null (or nullptr on error). */

0 commit comments

Comments
 (0)