同样的post请求代码在Java和android中执行结果不同。

同样的代码,在JAVA和android里得到的httpresponse不一样为什么呢?

主要代码如下。

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);

FileBody bin = new FileBody(new File(fileName));
StringBody comment = new StringBody("Filename: " + fileName);

MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("bin", bin);
reqEntity.addPart("comment", comment);
httppost.setEntity(reqEntity);

HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();

java得到的response内容
https://img1.mukewang.com/5cb43b2f0001315208000066.jpg

android得到的:

https://img1.mukewang.com/5cb43b31000136e208000169.jpg

PIPIONE
浏览 412回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java