- 浏览: 7807 次
- 性别:
- 来自: 济南
最新评论
package com.common;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.util.Base64Utils;
/**
*
* @author Administrator
*
*/
public class HttpClient {
public static Logger logger = LogManager.getLogger("xmllog");
public static String HMAC_SHA1_ALGORITHM = "HmacSHA1";
/**
* 向指定 URL 发送POST方法的请求
*
* @param url
* 发送请求的 URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
// 打印返回报文
StringBuffer loggerBugffer = new StringBuffer();//清空日志缓存
loggerBugffer.append("*************客户登录返回报文************ /n");
loggerBugffer.append(result+"/n");
loggerBugffer.append("*************客户登录返回报文************ ");
logger.info(loggerBugffer);
// 打印返回报文
return result;
}
/**
*
* DESCRIPTION:发送http请求
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @param charset
* @return
* @return String
* @throws
*/
public static String sendPost(String url, String param,String charset) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/xml;charset="+charset); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送post参数请求
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendPostparam(String url, String param,String charset) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset="+charset); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送JSON
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendJson(String url, String param) {
try {
URL add_url = new URL(url);
HttpURLConnection connection = (HttpURLConnection)add_url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Accept", "application/json"); // 设置接收数据的格式
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8"); // 设置发送数据的格式
connection.connect();
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(param.getBytes("utf-8"));
out.flush();
out.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String lines;
StringBuffer sbf = new StringBuffer();
while ((lines = reader.readLine()) != null) {
lines = new String(lines.getBytes(), "utf-8");
sbf.append(lines);
}
System.out.println(sbf);
reader.close();
// 断开连接
connection.disconnect();
return sbf.toString();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String sendPostDoCA(String url, String param,String charset,String signature) {
BufferedReader in = null;
DataOutputStream out=null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/xml;charset="+charset); // 设置发送数据的格式
conn.setRequestProperty("Content-Signature", "HMAC-SHA1 " + signature); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
out = new DataOutputStream(conn.getOutputStream());
out.write(param.getBytes("utf-8"));
out.flush();
out.close();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送JSON
* @author
* @date 2016年6月2日
* sendGet 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendGet(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
if(!"".equals(param) && param!=null){
int index = url.indexOf("?");
if(index > 0){
url = url+"&"+param;
}else{
url = url+"?"+param;
}
}
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.connect();
// 发送POST请求必须设置如下两行
// conn.setDoOutput(true);
// conn.setDoInput(true);
// OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
// writer.write(param);
// writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
logger.error("HttpClient.sendGet 发送 GET 请求出现异常:"+e.getMessage(),e);
System.out.println("发送 GET 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
// 打印返回报文
StringBuffer loggerBugffer = new StringBuffer();//清空日志缓存
loggerBugffer.append("*************客户登录返回报文************ /n");
loggerBugffer.append(result+"/n");
loggerBugffer.append("*************客户登录返回报文************ ");
logger.info(loggerBugffer);
// 打印返回报文
return result;
}
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.util.Base64Utils;
/**
*
* @author Administrator
*
*/
public class HttpClient {
public static Logger logger = LogManager.getLogger("xmllog");
public static String HMAC_SHA1_ALGORITHM = "HmacSHA1";
/**
* 向指定 URL 发送POST方法的请求
*
* @param url
* 发送请求的 URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
// 打印返回报文
StringBuffer loggerBugffer = new StringBuffer();//清空日志缓存
loggerBugffer.append("*************客户登录返回报文************ /n");
loggerBugffer.append(result+"/n");
loggerBugffer.append("*************客户登录返回报文************ ");
logger.info(loggerBugffer);
// 打印返回报文
return result;
}
/**
*
* DESCRIPTION:发送http请求
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @param charset
* @return
* @return String
* @throws
*/
public static String sendPost(String url, String param,String charset) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/xml;charset="+charset); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送post参数请求
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendPostparam(String url, String param,String charset) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset="+charset); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
writer.write(param);
writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送JSON
* @author
* @date 2016年6月2日
* sendPost 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendJson(String url, String param) {
try {
URL add_url = new URL(url);
HttpURLConnection connection = (HttpURLConnection)add_url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Accept", "application/json"); // 设置接收数据的格式
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8"); // 设置发送数据的格式
connection.connect();
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(param.getBytes("utf-8"));
out.flush();
out.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String lines;
StringBuffer sbf = new StringBuffer();
while ((lines = reader.readLine()) != null) {
lines = new String(lines.getBytes(), "utf-8");
sbf.append(lines);
}
System.out.println(sbf);
reader.close();
// 断开连接
connection.disconnect();
return sbf.toString();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String sendPostDoCA(String url, String param,String charset,String signature) {
BufferedReader in = null;
DataOutputStream out=null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Content-Type", "application/xml;charset="+charset); // 设置发送数据的格式
conn.setRequestProperty("Content-Signature", "HMAC-SHA1 " + signature); // 设置发送数据的格式
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
out = new DataOutputStream(conn.getOutputStream());
out.write(param.getBytes("utf-8"));
out.flush();
out.close();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream(),charset));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
/**
*
* DESCRIPTION:发送JSON
* @author
* @date 2016年6月2日
* sendGet 方法
* @param url
* @param param
* @return
* @return String
* @throws
*/
public static String sendGet(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
if(!"".equals(param) && param!=null){
int index = url.indexOf("?");
if(index > 0){
url = url+"&"+param;
}else{
url = url+"?"+param;
}
}
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.connect();
// 发送POST请求必须设置如下两行
// conn.setDoOutput(true);
// conn.setDoInput(true);
// OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
// writer.write(param);
// writer.flush();
// // 获取URLConnection对象对应的输出流
// out = new PrintWriter(conn.getOutputStream());
// // 发送请求参数
// out.print(param);
// // flush输出流的缓冲
// out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
logger.error("HttpClient.sendGet 发送 GET 请求出现异常:"+e.getMessage(),e);
System.out.println("发送 GET 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
// 打印返回报文
StringBuffer loggerBugffer = new StringBuffer();//清空日志缓存
loggerBugffer.append("*************客户登录返回报文************ /n");
loggerBugffer.append(result+"/n");
loggerBugffer.append("*************客户登录返回报文************ ");
logger.info(loggerBugffer);
// 打印返回报文
return result;
}
}
发表评论
-
项目发布的时候,提示jdk180 不支持
2016-06-02 21:08 492选中项目,alt+enter,进入属性界面,点击“java b ... -
jdk配置
2016-06-02 21:09 320JAVA_HOME D:\Program Files (x86 ... -
滚动条 固定到上次录入的地方
2011-09-09 17:34 492在<head> </head> 之间增 ... -
jxl操作excel文件---使用模板
2011-08-18 16:57 1020<%@ page contentType="t ... -
jxl操作excel文件---不使用模板
2011-08-18 16:55 914<%@ page contentType="t ...
相关推荐
利用httpclient-4.3.1.jar、httpcore-4.3.jar包,很简单的用java实现httpget和httppost请求。
HttpClient实现POST GET和文件下载 HttpClient实现POST GET和文件下载
MFC使用H偷偷跑Client的GET和POST方法 MFC使用H偷偷跑Client的GET和POST方法
一个简单的易学的 基于HttpClient 4.3发送psot及get请求,返回数据,适合初学者,适合初学者
httpclient的用法,发送get请求和post请求,设置header
http请求工具类HttpClientUtil,get,post请求(csdn)————程序
C++ 实现 HTTP HTTPS POST GET(包含curl版本和winhttp两种实现)。 玩过抓包,网络协议分析的朋友肯定都知道http https post get,web端和用户的交互主要是通过post get完成的。 我这里有两种实现: 1:libcurl实现的...
httpclient get/post请求工具类(map参数封装),方便调用
小小测试项目包含了4个知识点,其中包含了http协议向服务器传输数据的post和get方法,包含了httpclient传输方法,httpclient上传文件到服务器的方法,
java HttpClient 发送GET请求和带有表单参数的POST请求教程例子
本方法以HttpClient发送请求,并且接收返回数据 举例说明 public static String doGet(String url, Map, String> params, String charset) public static void downLoadImage(String url, String path) public ...
利用c# httpclient ,post json数据到web api
HttpClient模拟http发送post和get请求
HttpClient的简单使用,get、post、上传、下载。包含服务端和客户端代码
httpClient httpPost httpGet 所需jar包 httpClient httpPost httpGet 所需jar包
HttpClient发送http请求(post+get)需要的jar包+内符java代码案例+注解详解(这款工具类是我精心挑选适合广大java程序猿使用)
mfc http post 和get 请求
HttpClientUtil工具类发送get和post请求,支持http和https,支持发送文件
NULL 博文链接:https://javasam.iteye.com/blog/2117845