|
|
|
|
|
by jart
1863 days ago
|
|
thttpd has one cool cat badge icon but have you seen its critical path http parsing code? /* Read the MIME headers. */
while ( ( buf = bufgets( hc ) ) != (char*) 0 )
{
if ( buf[0] == '\0' )
break;
if ( strncasecmp( buf, "Referer:", 8 ) == 0 )
{
cp = &buf[8];
cp += strspn( cp, " \t" );
hc->referrer = cp;
}
else if ( strncasecmp( buf, "Referrer:", 9 ) == 0 )
{
cp = &buf[9];
cp += strspn( cp, " \t" );
hc->referrer = cp;
}
else if ( strncasecmp( buf, "User-Agent:", 11 ) == 0 )
{
cp = &buf[11];
cp += strspn( cp, " \t" );
hc->useragent = cp;
}
else if ( strncasecmp( buf, "Host:", 5 ) == 0 )
{
cp = &buf[5];
cp += strspn( cp, " \t" );
hc->hdrhost = cp;
Use perfect hash tables for known http headers, because they're perfect. |
|