???????????post????????????
??????????? ???????[ 2016/11/16 17:50:37 ] ??????????????? ??????
???????????????
????????????????????У????????????????????????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¶meter2=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????
??????
???·???
??????????????????
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