Various bug fixes

* Fixes lots of memory leaks
* Fixed lots of NULL pointer dereferences
* Fixes other issues found by clang scanbuild
http_response->lines is supposed to be an array of http_response->count allocated items of char *. So it makes no sense to check for http_response->lines and http_response->lines[i].