Java的Andr​​oid的,HTTPGET错误 - 主机名称不能为空 [英] Java Android , HttpGet error - Host name may not be null

查看:224
本文介绍了Java的Andr​​oid的,HTTPGET错误 - 主机名称不能为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HTTPGET得到一些图片的内容。它一直运作良好,但现在它给我的错误与我使用它的形式返回图像的新服务器:

I am using HttpGet to get the contents of some images. It has worked well but now it gives me errors with a new server I am using which returns images on the form of:

HTTPS://amx-sfs.qpass。 COM / D / DA / 207b3f6f-4fda-4faf-b7ae-a186530e1245

该错误是的主机名不能为空

我研究,似乎错误是常见的,当下划线出现在URL,但我的网址只包含连字符我认为这是由URI接受。反正我用下面的逃跑,但没有成功的网址也试过:

I have researched and it seems that the error is common when underscores appear on the URL, however my URL only contains hyphen which i think is accepted by URI. Anyway i also tried using the following to escape the url with no success:

HttpGet mHttpGet = new HttpGet(new URI(null,item.getImageUrl(),null));

还有什么可以引起问题,我该怎么解决呢?

What else can be causing the problem and how can i solve it?

在此先感谢

修改

我先用URL中使用直接试过

I first tried directly with the Url using

new HttpGet(item.getImageUrl())

然后我也试图与4 ARGS:

Then I also tried with 4 args:

HttpGet mHttpGet = new HttpGet(new URI("https","amx-sfs.qpass.com",item.getImageUrl().substring(25),null));

使用相同的结果,即使我调试HTTPGET对象,并观看了URI对象有,出现在主机属性OK(amx-sfs.qpass.com),但我仍然得到同样的异常。

With the same result, even if I debug the HttpGet Object, and watch the URI object it has, the host property appears ok (amx-sfs.qpass.com) , but I still get the same exception.

推荐答案

好了没有Java或Android的问题,导致服务器当它来自一个装置改变的请求......

Well there was no Java or Android problem, it results that the server changes the request when it comes from a device...

这篇关于Java的Andr​​oid的,HTTPGET错误 - 主机名称不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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