fix wrong header_size calculation, around keepalive code revert to old_style, and some changes