Refactored and fixed almost impossible memory leak.

Previously curl_slist_free_all(cHeaders) called in loop after
many break statements, so there was no garantue that it will be called
in all cases.

This change also simplifies code to make implementing PUT/DELETE methods
easier.