Re: [mongrel2] Handler Response Protocol Complete
- From:
- Colin Curtin
- Date:
- 2010-07-23 @ 16:39
Great work. I'll be able to update the Ruby lib on Monday. If anyone
needs it before then, feel free to do it and I'll pull in your
changes.
Colin
On Jul 23, 2010, at 1:05 AM, "Zed A. Shaw" <zedshaw@zedshaw.com> wrote:
> Hi Everyone,
>
> I implemented the handler response protocol just now, and updated the
> Python sample client to reflect it, so now people who are hacking on
> their own handlers should update to the new protocol for responses.
> It's very succinctly described in the src/handler_parsre.rl file:
>
> Identifier = digit+ ' '?;
> IdentList = (Identifier )**;
> Length = digit+;
> UUID = (alpha | digit | '-')+;
> Targets = Length ':' IdentList ",";
> Request = UUID ' ' Targets ' ';
>
> Which means if I send a message to server uuid=ASFASDF, and idents 10
> and 32, with the message "HI!" it looks like this:
>
> ASFASDF 5:10 32; HI!
>
> The parser also validates all lengths are correct, all characters are
> there and has assertions for buffer overflows. It's a fairly simple bit
> of code but is *much* more robust and faster than the last version of
> the same thing.
>
> But, for those of you who don't read "parser", here's the tests cleaned
> up so you can see what's being done:
>
> TEST("5a9a6354-fc33-4468-8ccd-5d736737dad7 2:12, The body");
> TEST("5a9a6354-fc33-4468-8ccd-5d736737dad7 11:0 1 2 3 4 5);
> TEST("5a9a6354-fc33-4468-8ccd-5d736737dad7 5:12 34, Another body.");
> TEST("5a9a6354fc3344688ccd5d736737dad7 5:12 34, ");
>
> And these are supposed to fail:
>
> TEST_FAIL("this.is.wrong 5:12 34, ");
> TEST_FAIL("5a9a6354fc3344688ccd5d736737dad7 10:12 34);
> TEST_FAIL("5a9a6354fc3344688ccd5d736737dad7 3:12 34);
> TEST_FAIL("5a9a6354fc3344688ccd5d736737dad7 5:12 34);
> TEST_FAIL(" 5:12 34,");
>
> Your old messages will result in a successful parse, but with 0 targets
> sometimes, so Mongrel2 catches that and says it's an error.
>
> Alright, I'll be in the channel for those working to update to this and
> need help. I'm also going to figure out how to get something like
> SCRIPT_PATH going.
>
> --
> Zed A. Shaw
> http://zedshaw.com/