added http close for header request, fixed a few bugs and added a few comment