我的http Get call格式就像这样……
url = new URL(urlString); //httpURLConnection = (httpsURLConnection) url.openConnection(); httpURLConnection = (httpURLConnection) url.openConnection(); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setRequestProperty("Connection","keep-alive"); httpURLConnection.setRequestProperty("Accept","application/Json"); // or application/Jsonrequest httpURLConnection.setRequestProperty("Content-Type","application/Json"); /* httpURLConnection.setRequestProperty("Content-Type","application/Json");*/ httpURLConnection.setRequestProperty("UsecookieContainer","True"); httpURLConnection.setRequestProperty("cookie",cokIEValue); httpURLConnection.connect();解决方法 一旦检查了服务器端代码..
即将到来意味着改变这样的代码……
url = new URL(urlString); httpURLConnection = (httpsURLConnection) url.openConnection(); //httpURLConnection = (httpURLConnection) url.openConnection(); // httpsURLConnection.setDefaultHostnameVerifIEr(new NullHostnameVerifIEr()); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setRequestProperty("Connection","keep-alive"); httpURLConnection.setRequestProperty("Content-Type","application/Json"); httpURLConnection.setRequestProperty("UsecookieContainer","True"); httpURLConnection.setChunkedStreamingMode(0); httpURLConnection.connect(); if (httpURLConnection != null) { respCode = httpURLConnection.getResponseCode(); messageStatus.setResponseCode(respCode); } if (respCode == 200) { inputStream responseStream = httpURLConnection.getinputStream(); messageStatus.setResponseStream(responseStream); }总结
以上是内存溢出为你收集整理的android – Http Get Request返回html?全部内容,希望文章能够帮你解决android – Http Get Request返回html?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)