fixing http post error, was not properly closing connection