Permalink
Browse files

new version

Trashing the old Ragel parser (which was based on Mongrel) because it's
proving difficult to get the control I need in end-of-message cases.
Replacing this with a hand written parser using a couple tricks borrowed
from NGINX. The new parser will be much more work to write, but should prove
faster and allow for better hacking.
  • Loading branch information...
1 parent 6bfd5bf commit 433202d825fa34de5e42f810bb984ece05a36d20 @ry ry committed Nov 17, 2009
Showing with 985 additions and 656 deletions.
  1. +0 −1 .gitignore
  2. +4 −7 Makefile
  3. +891 −0 http_parser.c
  4. +12 −81 http_parser.h
  5. +0 −536 http_parser.rl
  6. +78 −31 test.c
View
@@ -1,4 +1,3 @@
tags
*.o
test
-http_parser.c
View
@@ -1,24 +1,21 @@
-#OPT=-O0 -g -Wall -Wextra -Werror
-OPT=-O2
+OPT=-O0 -g -Wall -Wextra -Werror
+#OPT=-O2
test: http_parser.o test.c
gcc $(OPT) http_parser.o test.c -o $@
http_parser.o: http_parser.c http_parser.h Makefile
gcc $(OPT) -c http_parser.c
-http_parser.c: http_parser.rl Makefile
- ragel -s -G2 http_parser.rl -o $@
-
-tags: http_parser.rl http_parser.h test.c
+tags: http_parser.c http_parser.h test.c
ctags $^
clean:
rm -f *.o http_parser.c test http_parser.tar
package: http_parser.c
@rm -rf /tmp/http_parser && mkdir /tmp/http_parser && \
- cp LICENSE README.md Makefile http_parser.c http_parser.rl \
+ cp LICENSE README.md Makefile http_parser.c \
http_parser.h test.c /tmp/http_parser && \
cd /tmp && \
tar -cf http_parser.tar http_parser/
Oops, something went wrong.

6 comments on commit 433202d

Happy to see you going by hand, but the Ragel parser had the advantage of the graphical Dot state machine output. Are you maintaing a similar FSM for this version, and if so, would you please copy the .Dot file into the repository? Thanks!

Contributor

ry replied Nov 21, 2009

no, unfortunately not.

Contributor

temoto replied Nov 23, 2009

And new parser will not support custom methods?

Contributor

ry replied Nov 24, 2009

no

Hello,

I noticed that lines 771-781 in http_parser.c allow an HTTP header to contain only the field name, without the ':'.
For example, we could have a header like this:

"Accept-Encoding\r\n"

But, section 4.2 of HTTP RFC 2616 specifies that an HTTP header is defined like this:

message-header = field-name ":" [ field-value ]

, having the ':' character compulsory.

I am having some problems with this, and I was thinking of commenting out lines 771-781. Does anyone happen to know if this would have negative effects on the rest of the parser's functionality?

Thanks,
Claudiu

Member

bnoordhuis replied Apr 20, 2013

I wager you're looking at an old version of http-parser. With the current master (8081938) the logic you describe is around line 1300. But yeah, it will accept headers without values for the sake of interoperability (think: buggy servers.)

Please sign in to comment.