Deprecation fix apache.httpcomponents

fix deprecation due to apache.httpcomponents upgrade and fixing some
code warnings