[AWS] Cookie bug

Maciej Sobczak prog at msobczak.com
Tue Jan 10 23:04:57 CET 2012


On 10/01/2012 13:46, Thomas Løcke wrote:

> That Get function is actually not only buggy, it's also pretty poorly
> made I think.
>
> As far as I can see, I'm searching the entire cookie string
> from AWS.Headers.Get_Values, which is stupid (and bad!), considering I
> can search individual cookies by looping
> the Containers.Tables.VString_Array instead.

I'm not sure this would be much better idea. You can assume that the 
number of cookies is small and that their values are reasonably short 
(that is, if you have tons of cookies or they are huge, then you should 
rethink the state management in your web service), in which case a 
simple linear search over an array of characters is probably the fastest 
thing you can ever do (hint: cache, prefetch, etc.).
Building some dynamic multi-node data structure from this simple array 
would be much workse performance-wise. There is no added value from it 
and surely lots of overhead.

After second look, all functions in this package are f*cked up for other 
reason as well: consider several cookie names that are substrings of 
each other, like "USER_ID=abc" and "SUPER_USER_ID=xyz" and the following 
expression:

Index (Cookie, Key & "=")

Now, "USER_ID=" can be found in both. All functions from this package 
have this bug.

> I will fix this as soon as possible,

Don't hesitate to propose the solution, I will try it as well.

Regards,

-- 
Maciej Sobczak * www.msobczak.com * www.inspirel.com


More information about the AWS mailing list