At the moment, I'm reading this: http://pragprog.com/articles/tell-dont-ask and http://robots.thoughtbot.com/post/27572137956/tell-dont-ask
It gave me some ideas, for example, move the detection of document end to http_client.
To do this, I'll need to parse chunked encoding.
But, the http_client and http_server will be more standalone and possibly would permit to transform them into gen_fsm, with two states: send and receive