I see the http parser written by Igor Sysoev for nginx does not use regular expressions
https://github.com/joyent/http-parser
What could be the main reason for such design decision? I guess I could write few regular expressions to parse HTTP req & res this would be a lot less complex than Igor’s version of the parser.
What am I missing here?
8
I asked this question over the mailing list of nginx. The following was the response:
Regular expressions isn’t something readily available when you
code in C, nor something which can be easily used to parse data
available in chunks. It’s also highly unlikely that even
carefully coded regular expressions will be able to beat C code in
terms of performance.Of course if you are coding some simple http server in perl or
javascript – using regular expressions is a way to go. But it’s
unlikely a good choise if you are coding high performance web
server in C.
— Maxim Dounin (member of nginx dev mailing list)
1