下面有一个java示例代码。它可以使用charset utf-8向服务器发送http post请求。我怎样才能在linux c程序中做同样的事情?
private String message = "3";
private String trading = "AAAAA";
private String document = "BBBBB";
private String targetURL = "http://10.1.2.3/param";
HttpPost httppost = new HttpPost(targetURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("message", message));
params.add(new BasicNameValuePair("trading", partner));
params.add(new BasicNameValuePair("document", document));
params.add(new BasicNameValuePair("requestMessage", requestMsg));
HttpEntity request = new UrlEncodedFormEntity(params, "UTF-8");
httppost.setEntity(request);
HttpResponse httpResponse = httpclient.execute(httppost);
HttpEntity entity = httpResponse.getEntity();
String result = null;
if (entity != null) {
result = EntityUtils.toString(entity);
}
在 Linux C 中,什么 http post 请求可以达到与 java 代码剂量相同的目标?eg.如何将字符集设置为 utf-8 并且:“message”、“trading”、“document”在 http post 请求的头部或正文中?
这两个问题真的让我很困惑。