I am learning Go and I thought it would be a good exercise to implement my own HTTP 1.1 parser using Ragel and Go. I thought it would be a good idea to have a look at the code base of Mongrel2 to see how it's done.
The code for Mongrel's HTTP parser is here and I have a difficulty understanding the highlighted function http11_parser.c which seems to do the actual HTTP processing.
My questions are as follows:
- In plain English, what's the underlying idea behind the implementation? What does the code do?
- Assuming that there is such a thing as idiomatic C, is this code a good example of it? If not, is there a reason for all these gotos, nested if and switches?
PS. Regarding Q2, the only explanation I could find for using the goto is here. Note that my experience with C is 0.5 (on the scale from 1 - 10) which explains why I am having difficulty understanding this code!