【问题标题】:URL rewrite at Android httpGet + InputStreamReader在 Android httpGet + InputStreamReader 重写 URL
【发布时间】:2011-06-22 21:23:12
【问题描述】:

如果我有这段代码并且 url 是 "http://www.example.com/someFile.txt" 一切正常。但是,如果我把 "http://www.example.com/export/something" (在服务器上的 URL rewrite/.htaccess 的帮助下)在桌面浏览器中再次在 Android 中输出相同的结果我收到错误 Error w/file: End of input at character 0 of

    HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();

    String result = "";
    HttpGet httpGet = new HttpGet("http://www.example.com/export/notWorking");
    HttpResponse response = null;
    try {
        response = httpClient.execute(httpGet, localContext);
        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String line = null;
        while ((line = reader.readLine()) != null){
            result += line;
        }
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

解决这个问题很热门?

编辑:用户代理帮助

    HttpParams params = new BasicHttpParams();  
    params.setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71");

没有帮助。

【问题讨论】:

    标签: android url-rewriting inputstream http-get


    【解决方案1】:

    解决方案 - 非常微不足道 我必须说 - 我删除了模拟器,创建了一个新模拟器,然后一切正常......所以将来 - 仅在 设备上测试 本身:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-23
      • 1970-01-01
      • 1970-01-01
      • 2013-02-22
      • 1970-01-01
      • 2012-04-30
      • 2015-01-04
      • 2014-11-29
      相关资源
      最近更新 更多