File extension lookup table - advice needed
This is for a Spinneret web server project. The client requests a file resource via HTTP. It could be .htm, gif, whatever. In the response, I send back the proper content-type header. Currently, the logic is wrapped in a bunch of SPIN < if string1 == string2 …elseif…> logic blocks. I want to replace the IF blocks.
I started looking at a hash table but I would need 26^3 rows for 3 lowercase alpha characters. I only need around 30ish rows. I would like to do the same kind of look-up table method for HTTP response codes like “200 OK”.
If someone can point me in the right direction, that would be much appreciated.
I started looking at a hash table but I would need 26^3 rows for 3 lowercase alpha characters. I only need around 30ish rows. I would like to do the same kind of look-up table method for HTTP response codes like “200 OK”.
If someone can point me in the right direction, that would be much appreciated.
Comments
-Phil
con HTML = "H"<<16+"T"<<8+"M" GIF = "G"<<16+"I"<<8+"F" pub testit | ext,idx ' this should copy the extension from wherever you have it in your code into a known long byte[@ext+3]:=0 byte[@ext+2]:="H" byte[@ext+1]:="T" byte[@ext+0]:="M" ' here you will then find either an index of 1 to 2 in this case ' or a 0 if the extension is not found in the list idx:=lookdown( ext: HTML, GIF )
tmp:=lookup( idx: string("text/html"), string("media/gif",13) )
Thanks for your input!