Source

Both Request and Response types provide a constructor named a source that takes a function as an argument, this function should behave similar to luasocket’s tcp receive method. To be more specific the function should take 1 argument, that argument should be either '*a', '*l', or a number; if omitted it will default to '*l'. The return value for this has some additional constraints, first is that it must return a single line (with new line characters stripped) until after the trailing new line that signals the last header has been received.

To ease the use of the source method the luncheon.utils module exposes a few helpers like the tcp_socket_source which works exactly as described above. Either Request or Response parser will call the source provided with '*l' until the end of the headers have been reached.