Cannot get httpResponse content

前端 未结 1 1831
迷失自我
迷失自我 2021-02-11 06:18

I didn\'y manage to query a web service from android emulator (previously I had a UnresolvedHostException but this is ok). Now that I can go any further, I do not have anything

相关标签:
1条回答
  • 2021-02-11 07:16

    Don't rely on the content length. Sometimes it is unable to find the content length so just retrieve the returned data

    URL url = new URL("xyz.com";); 
    URLConnection conn = url.openConnection();
    conn.setRequestProperty("Authorization", "Basic"+getcredentials());
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    //read d response till d end
    while ((line = rd.readLine()) != null) {//process the line response}
    
    0 讨论(0)
提交回复
热议问题