现在的位置: 首页 > 综合 > 正文

在android4.0中http get请求自动变成post请求

2013年10月28日 ⁄ 综合 ⁄ 共 528字 ⁄ 字号 评论关闭

昨天发现一个奇怪的现象,我一个普通的HTTP GET请求下载apk文件,服务器却总是返回405 Method Not Allowed。百思不得其解。
今天我用wireshark抓取数据包发现,发出去的请求居然不是GET ,而是POST !!!
代码如下(部分):

?
代码片段,双击复制
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
//MalformedURLException:
a MalformedURLException may be thrown here
    
   
URL
url =
new

URL(_url);
 
    
   
//a
IOException may be thrown here eg:UnknownHostException
    
   
try

{
    
       
conn
= (HttpURLConnection) url.openConnection();
    
   
}
catch

(IOException e) {
    
       
e.printStackTrace();
    
       
throw

e;
    
   
}
    
   
//a
IOException may be thrown here eg:ProtocolException, but it's unusual

抱歉!评论已关闭.