Call for testing: Luncheon

I have completed a series of updates to the http parser/generator library Luncheon but before I request the changes get pulled into the lua_libs I want to get a little more confidence in the changes. In order to do this I am asking anyone in the driver developer community to try patching this library in their drivers to see if these changes cause any issues. Directions for how to include these changes in a driver are below.

First clone the luncheon repository and checkout the misc-fixes branch and then copy the luncheon sub-directory into the driver’s src directory

git clone https://github.com/cosock/luncheon
cd ./luncheon
git checkout misc-fixes
cp ./luncheon /path/to/driver/src

As an example here is how I’ve done this in my http_button driver.

If you are using Luncheon in any of your drivers I would really appreciate some extra runtime on these changes. If you do end up trying to test this please reply here with either a success or failure.

The changes include the following

  • Chunk encoding parsing on requests and responses with a source when the Transfer-Encoding header is set to chunked
  • iter and serialize now work for both builders and source based requests and responses
  • send will call self.sock.send with up to 1024 bytes instead of just the next line
  • Headers now has an explicit append and replace method for controlling duplicate headers
    • Previously multiple calls to append would only select the last entry when serializing, now all entries will be serialized
    • Request/Response helpers set_content_length and set_content_type will now use the replace method to avoid duplicate entries for these values.
    • Request/Response types now have a replace_header method for accessing this w/o calling get_headers directly.
  • Request:content_length has been marked as deprecated in favor of Request:get_content_length which better matches the Response method.
  • Request.new no longer sets the content-length header to 0 on construction
  • A large amount of the parse/generate logic has been centralized to be shared across both the Request and Response types.

Some of the key things I am looking to get a handle on are

  • Are any of the changes made non-backwards compatible?
    • Missing methods or fields (anything prefixed with a _ according to convention is not considered public)
  • Does the new chunk encoding parse incoming requests/responses correctly?
  • Does the changes to the Headers type negatively impact existing uses?

Please reach out here if you have any questions and/or feedback. Thank you in advance!

3 Likes

I will definitely give it a go. I wrote my own chunked transfer logic on top of luncheon, so I’ll compare the code as well as swap it out for test.

I gave this branch a shot and the chunked encoding does work. It wasn’t a direct drop in replacement. I started by just trying to use the library without any code modifications. There were conflicts with my own chunked response handling. I had to remove my handling code and use Response.tcp_response directly. At that point it worked well with a single http request and handled the chunked transfer. However, it wasn’t compatible with my keep-alive implementation. The first request worked fine, but any other calls were “closed by peer” or had SSL errors. DM me if you want more info or code samples.

Thanks for the updates. Glad luncheon keeps evolving :+1:

Thank you so much for the feedback! Glad things are mostly working for you.