rework http_keep_alive mechanism, some code reformatting