This happens in src/response and is responsible for (according to profiles) 60+% of the running time of the server.