“响应中不包含内容类型”

时间:2012-09-10 07:19:00

标签: android

“响应中不包含内容类型”??

这里我在我的应用程序中构建连接以获取XML:

     try {

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(uri1);

        if(list!=null)
        {
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(list);

        httpPost.setEntity(formEntity);
        }
         URI uri=httpPost.getURI();
        HttpResponse httpResponse = httpClient.execute(httpPost);



        StringBuffer sb = new StringBuffer("");
        String line = "";
        String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
              sb.append(line + NL);
        }
        in.close();

        result = sb.toString();


}
    catch(UnsupportedEncodingException e)
    {
        String err = (e.getMessage()==null)?"Cant connect to server":e.getMessage();
        Log.e("Network Error:",err); 
    }
    catch (MalformedURLException e) {
        String err = (e.getMessage()==null)?"Malformed Exception":e.getMessage();
        Log.e("Malformed Exception:",err); 

     } 
     catch(Exception ex)
     {
         Log.i("Exception,ex", ex.getMessage());
         String err = (ex.getMessage()==null)?"NetworkConnectionException":ex.getMessage();
         Log.e("NetworkConnectionException:",err); 
     }
    finally {
        if (in != null) {
            try {
                    in.close();
             } catch (Exception ex) {
                 String err = (ex.getMessage()==null)?"Excepion":ex.getMessage();
                 Log.e("Exception:",err); 
            }
        }

     }

    return result;

我在这里使用的URL是带RSS源的博客URL

并且作为响应,错误是:“响应不包含内容类型”或“内容已被消耗”

我已经尝试了一切,但仍未成功..请帮助

[被修改]: 用于获取XML的普通URL工作正常,但此博客URL给我这个错误

0 个答案:

没有答案