HttpClient异常:java.lang.IllegalArgumentException:主机参数为null [英] HttpClient exception: java.lang.IllegalArgumentException: host parameter is null

查看:163
本文介绍了HttpClient异常:java.lang.IllegalArgumentException:主机参数为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下一个代码

    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:主机参数为空"

在client.executeMethod调用上.

on client.executeMethod call.

为什么会这样?

推荐答案

这是代理的书面示例 http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/ProxyTunnelDemo.java?view = co <​​/a>就我而言,问题在于hostConfiguration的创建

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

这篇关于HttpClient异常:java.lang.IllegalArgumentException:主机参数为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆