2010-08-18 34 views
2

我使用Apache的HttpClient通过httpclient-fluent-builder下载http页面。不能用HttpClient下载不同的服务器端口

这是代码:

... 
try { 
    response = Http.get("http://fr3.ah.fm:9000/played.html") 
     .use(client)    // use this HttpClient (required) 
     .charset("windows-1252")  // set the encoding... (optional) 
     .asString(); 
} catch (IOException e) { 
    Log.d(TAG, "Error: "+e.toString()); 
    e.printStackTrace(); 
} 
Log.i(TAG, ""+ response); 
... 

问题是,我得到org.apache.http.client.ClientProtocolException

这件事情与主机:端口/ URL,东阳它的URL不工作端口。我还得到了另一个Httphelper类与流利构建器相同的错误。防火墙关闭。

的logcat:http://pastebin.com/yMMvvdQ3

+0

如果您在浏览器中点击http://fr3.ah.fm:9000/played.html,它会给你一些有效的东西? – 2010-08-18 22:46:14

+0

是的,我试着从我的常规浏览器和模拟器内的Android浏览器。 – droidgren 2010-08-18 23:21:40

回答

2

发现了什么,然后经此post这是SHOUTcast服务器...

你应该能够与您的网络连接到8000 浏览器并获取DNAS 状态页面。另一方面,如果您使用媒体 连接到该端口,它将返回直接MP3 流。 (不幸的是,在一个令人难以置信的 一件愚蠢的设计, 方式Shoutcast一样决定要 响应与是通过嗅探你 User-Agent头的东西 使用Mozilla开始,因此,如果您使用其他浏览器是 或 阻止您的UA你不能 获取状态,如果流的 下来,你可能只是什么也得不到。)

开车送我疯了..但它是一个容易解决。我刚刚添加。

.header("User-Agent", "UserAgent: Mozilla/5.0") 
+0

你不知道你为我节省了多少努力。谢谢! :) – 2012-07-02 19:57:39

0

尝试使用HttpHost设置URI和HttpClient.execute使用它()。

我还没有尝试过..

相关问题