javaapachehttp

HttpClient exception: java.lang.IllegalArgumentException: host parameter is null


I have next code

    URL targetUrl = ...
    HttpClient client = new HttpClient(connectionManager);
    GetMethod getMethod = new GetMethod();
    getMethod.setPath(targetUrl.getPath());

    HostConfiguration hostConfiguration = getConfiguration(targetUrl) //unknown lib code

    client.executeMethod(hostConfiguration, getMethod);

In some cases(on some hosts) I get

java.lang.IllegalArgumentException: host parameter is null"

on client.executeMethod call.

Why may this happen?


Solution

  • This is a write exampe of proxy http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/ProxyTunnelDemo.java?view=co In my case problem was in hostConfiguration creation