Added some safety checks in case of HTTP errors (abort request & close connection).