Generalised the HTTP client a bit.