???????????????
????????????????????У????????????????????????fiddler????HttpClient???
????Fiddler?????????httpЭ????????????????????????????????????http?????????????
??????????????HttpClient???????????????Apache?????HttpComponent???????????????HttpComponent?????????????????????HttpCore??HttpClient???AsynchHttpClient??????HttpComponent??????????HttpCore?????HTTP???????????С??????????????????????????Http????HttpClient???????HttpCore????Http??????????? ????????????Ч????μ????????????HTTPЭ???????????????Asynch HttpClient??????HttpCore???????????????????????????????????http???????????????????????????????????????????
????????????У?????????get???????post????get???????????????????????ú????????????urlд??????ɡ??????????post???????????????????????????????????????????????????????????????????????£??????????Ч???
??????????????????post????????????????????????????fiddler??HttpClient???????????????
????????post???????????
?????????????post????????????????У???????????????壬???
????<method><url><version>
????<headers>
????<entity-body>
????????get??????????????????entity-body??????post??????????????????????????????????????????????????????????????????????????????????????????????????????ν??????????????????????е?Content-Type?????????????????????????????Content-Type?????????????????????????????????Content-Type????????????????application/x-www-form-urlencoded????????????????application/json??text/xml???multipart/form-data?????
??????Щ?????post??????????????HttpEntity???????б?????????HttpClient??HttpEntity??????????е?post????????????????HttpEntity????н??з????HttpEntity?????????????????????????к???????????StringEntity??UrlEncodedFormEntity???????StringEntity????MultipartEntity???????????????????post?????????????????????????????????????????fiddler????????httpClient???????java??????????????
????????????Post????????????fiddler??HttpClient?????????
?????????application/x-www-form-urlencoded??????
??????W3C?????????????????????????????壺
????This is the default content type. Forms submitted with this content type must be encoded as follows:
????Control names and values are escaped. Space characters are replaced by '+'?? and then reserved characters are escaped as described in [RFC1738]?? section 2.2: Non-alphanumeric characters are replaced by '%HH'?? a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e.?? '%0D%0A').The control names/values are listed in the order they appear in the document. The name is separated from the value by '=' and name/value pairs are separated from each other by '&'.
????????post??????????????????????????????????????name???????????value??????????????????????name/value??????&?????????磺parameter1=12345&parameter2=23456???????????????и????????????????????????????????????????????????????????getParameters??String name???????????????????????
?????????????η????fiddler??HttpClient??????post????
??????1???????fiddler??????????????????????????????????????????

??????????????????????????????????????????

??????2???????HttpClient???post???????????????????????
DefaultHttpClient client = new DefaultHttpClient();
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();     //?????????б??????????url????post??????????
params.add(new BasicNameValuePair("parameter1"?? "12345"));
params.add(new BasicNameValuePair("parameter2"?? "23456"));               //??params????????
HttpPost post = new HttpPost("http://example.com");                      //????HttpPost???????????
HttpEntity reqEntity = new UrlEncodedFormEntity(params);                 //??UrlEncodedFormEntity????????????????
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????????
??????????application/json??????
????application/json?????????????????????????post?????????????????л???? JSON ???????
??????1???????fiddler??????????????????????????????????????????

??????????????????????????????????????????

??????2???????HttpClient???post???????????????????????
HttpClient client = new DefaultHttpClient();
JSONObject js = new JSONObject();                                  //???????JSON?????????????????????????????
js.element("parameter1"?? "12345");                                 //?JSON????????key????
js.element("parameter2"??"23456");
String postRequest = js.toString();
HttpPost post = new HttpPost("http://example.com");                 //????HttpPost???????????
StringEntity reqEntity = new StringEntity(js.toString());           //??StringEntity????????????????
reqEntity.setContentType("application/json");                       //??????????????????
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????????
??????????????????HttpClient???post????????????????application/x-www-form-urlencoded??application/json????????????????????????????????????????????JSON????????????????????????????????????UrlEncodedFormEntity????????StringEntity????