On Wed, Feb 04, 2009 at 11:27:24PM -0800, Drew Hess wrote: > Hi, > > The regex used to parse HTTP headers in http:read-request-attributes in the > http egg isn't quite right. > > (let ((rx (if (feature? 'pregexp) > "([\\-A-Za-z0-9]+):[ ]*([^ ].*)" > "([-A-Za-z0-9]+):[ ]*([^ ].*)") ) ) > > RFC 2616 states in Section 4.2 that HTTP headers "follow the same generic > format as that given in Section 3.1 of RFC 822." That means HTTP header > field values may contain quoted strings with spaces, may be empty, > or may even be multi-line (ugh).
You're right, this regex is wrong here. > Unfortunately, properly parsing RFC 822 headers looks pretty hairy, > mainly due to the multi-line case. Yeah, you can say that again :). Because of the hairiness of the RFC and the current brittleness of the HTTP egg (it has been hacked to pieces, and accumulated quite a bit of cruft) I decided to start from scratch on a new HTTP egg. That new egg is called "intarweb", and it at least has a testsuite (probably not big enough yet). Unfortunately, it's Chicken 4 only, and not completely finished right now, so it won't help you right this moment (unless you can switch), but I hope this gives you some new hope :) For the time being, I changed the HTTP egg's regex to remove the "nonspace character" match at the start of the submatch group, so "Foo: " and "Foo:" are allowed header values. Please give the new trunk a shot, and let me know whether it works for you. It hasn't been tagged yet, so it's not available through chicken-setup yet, but you can fetch the trunk from https://galinha.ucpel.tche.br/svn/chicken-eggs/release/3/http/trunk (username: anonymous, no password) Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth
pgp6m5LHfbbOO.pgp
Description: PGP signature
_______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
