ryah ([info]four) wrote,
@ 2009-04-27 17:21:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Entry tags:programming

HTTP Parser
I extracted the HTTP parser from libebb and beefed it up. It now handles HTTP responses, and I gave it a bit of documentation, made various other little improvements.

    * No dependencies
    * Parses both requests and responses.
    * Handles keep-alive streams.
    * Decodes chunked encoding.
    * Extracts the following data from a message
          o header fields and values
          o content-length
          o request method
          o response status code
          o transfer-encoding
          o http version
          o request path, query string, fragment
          o message body


source repo: http://github.com/ry/http-parser/tree/master

version 0.1: http://s3.amazonaws.com/four.livejournal/20090427/http_parser-0.1.tar.gz



(2 comments) - (Post a new comment)

Caching
(Anonymous)
2009-04-27 05:17 pm UTC (link)
Do think there would be any benefit to caching parse/dispatch results for all or part of the header pipeline?

Seems like some packrat-style optimizations might yield gains.

(Reply to this) (Thread)

Re: Caching
[info]four
2009-04-27 06:05 pm UTC (link)
I doubt many applications are bottlenecked at parsing. It's an interesting idea since many requests are similar but I would want to see http_parser_execute() show up in a profiler and go through some optimization with the above code.

(Reply to this) (Parent)


(2 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…