码迷,mamicode.com
首页 > 编程语言 > 详细

java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, path=/

时间:2018-08-14 14:29:17      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:eth   ade   ide   final   问题   targe   request   err   name   

使用的 xutils

出现标题中的错误

 

原因:没有添加 Cookie

 

1 params.addHeader("Cookie", CurrentUserSettings.getCookies());

加上之后问题解决

Cookie通过以下方式获取

   final HttpUtils httpUtils = new HttpUtils();
        params.setPriority(Priority.BG_TOP);
        httpUtils.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                DefaultHttpClient defaultHttpClient = (DefaultHttpClient) httpUtils.getHttpClient();
                List<Cookie> cookies = defaultHttpClient.getCookieStore().getCookies();
    
                if (cookies.size() > 0) {

                    CurrentUserSettings.setCookies(cookies.get(0).getName() + "=" + cookies.get(0).getValue());
                }

             
            }
}

 

java.io.IOException: Target host must not be null, or set in parameters. scheme=null, host=null, path=/

标签:eth   ade   ide   final   问题   targe   request   err   name   

原文地址:https://www.cnblogs.com/tomarsNi/p/9473629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!