???????????post????????????
??????????? ???????[ 2016/11/16 17:50:37 ] ??????????????? ??????
??????????text/xml??????
??????1???????fiddler??????????????????????????????????????????
??????????????????????????????????????????
??????2???????HttpClient???post???????????????????????
Document doc = DocumentHelper.createDocument(); //????document????
Element book = doc.addElement("book"); //????document??????????
book.addElement("title").addText("???′?");
book.addElement("author").addText("?????");
String body = book.asXML(); //Document???????string????
StringEntity reqEntity = new StringEntity(body); //??StringEntity????????????????
reqEntity.setContentType("text/xml"); //??????????????????
reqEntity.setContentEncoding("utf-8"); //??????????????????
HttpPost post = new HttpPost("http://example.com"); //????HttpPost???????????
post.setEntity(reqEntity); //????post???????
HttpResponse response = client.execute(post); //????http????
System.out.println("the request body is:"+EntityUtils.toString(reqEntity)); //????????????
System.out.println(response.getStatusLine().getStatusCode()); //???http????????
?????????multipart/form-data??????
????????????application/x-www-form-urlencoded???????????????????????????????????????????????????multipart/form-data????HttpClient???????????HttpMime??????????????????????????MultipartEntity??????????????HttpEntity????
??????1???????fiddler??????????????????????????????????????????
????????????????ú????????????????upload file...
??????????????????????????????????png????
????????fiddler????????????????????????????????????????п?????????????????????????“?????”??boundary??????????“???????”?????????????????????????????????δ???????“??????????”????????ɡ????post?????????????????????30-40λ???????????????????????????????post????????????????????????????????е???????????????????ɡ?????????????????????????????Content-Type ???洫?????????????????????????????????????????????boundary????Σ????α???????????(???field?????С???????????????value??"form-data"??"Content-Disposition"??????????"name"??????field??ID?????????????????filename)
??????????????????????????????????????????
??????2???????HttpClient???post???????????????????????
????HttpPost post = new HttpPost("http://example.com"); //????HttpPost???????????
????MultipartEntity mutiEntity = new MultipartEntity(); //????MultipartEntity????
????File file = new File("C:UsershzsuixiangDesktopimage_20151117151539.png");
????mutiEntity.addPart("desc"??new StringBody("?????????"?? Charset.forName("utf-8"))); //????multiEntity?????????????
????mutiEntity.addPart("pic"?? newFileBody(file));post.setEntity(mutiEntity); //????post????????
????HttpResponse httpResponse = client.execute(post); //???post????
????HttpEntity httpEntity = httpResponse.getEntity(); //?????????????
??????????????????fiddler??HttpClient???post??????????????????????????????????????????????????????п???????????????????????????????г?????Щ?????в????д???????jar?????????????????????????
?????????飺http://www.jianshu.com/p/3b6d7aa2043a
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11