JAVA HttpClient 远程调用接口doGet、doPost工具类,java分布式开发面试题

一. 什么是架构和架构本质

在软件行业,对于什么是架构,都有很多的争论,每个人都有自己的理解。 此君说的架构和彼君理解的架构未必是一回事。因此我们在讨论架构之前,我们先讨论架构的概念定义,概念是人认识这个世界的基础,并用来沟通的手段,如果对架构概念理解不一样,那沟通起来自然不顺畅。

Linux有架构,MySQL有架构,JVM也有架构,使用Java开发、MySQL存储、跑在Linux上的业务系统也有架构,应该关注哪一个?想要清楚以上问题需要梳理几个有关系又相似的概念:系统与子系统、模块与组建、框架与架构

}

return httpClient.execute(request);

}

/**

  • Put stream

  • @param host

  • @param path

  • @param method

  • @param headers

  • @param querys

  • @param body

  • @return

  • @throws Exception

*/

public static HttpResponse doPut(String host, String path, String method,

Map<String, String> headers,

Map<String, String> querys,

byte[] body)

throws Exception {

HttpClient httpClient = wrapClient(host);

HttpPut request = new HttpPut(buildUrl(host, path, querys));

for (Map.Entry<String, String> e : headers.entrySet()) {

request.addHeader(e.getKey(), e.getValue());

}

if (body != null) {

request.setEntity(new ByteArrayEntity(body));

}

return httpClient.execute(request);

}

/**

  • Delete

  • @param host

  • @param path

  • @param method

  • @param headers

  • @param querys

  • @return

  • @throws Exception

*/

public static HttpResponse doDelete(String host, String path, String method,

Map<String, String> headers,

Map<String, String> querys)

throws Exception {

HttpClient httpClient = wrapClient(host);

HttpDelete request = new HttpDelete(buildUrl(host, path, querys));

for (Map.Entry<String, String> e : headers.entrySet()) {

request.addHeader(e.getKey(), e.getValue());

}

return httpClient.execute(request);

}

@SuppressWarnings(“resource”)

public static String doPost(String host, String path,String jsonstr,String charset){

String url=host+path;

HttpClient httpClient = null;

HttpPost httpPost = null;

String result = null;

try{

httpClient = wrapClient(host);

//------------------------------4.1,4.2 版本设置时间-----------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值