Refactor code to remove dependency on v4.2 of HttpComponents