内容简介:smart-http 是一款可编程的 Http 应用微内核,用户可根据自身需求进行 Server 或 Client 的应用开发。 你可以基于它开发 HTTP 代理服务器、网关、静态服务器、http client 工具、性能压测工具等。smart-http 依旧...
smart-http 是一款可编程的 Http 应用微内核,用户可根据自身需求进行 Server 或 Client 的应用开发。
你可以基于它开发 HTTP 代理服务器、网关、静态服务器、http client 工具、性能压测 工具 等。smart-http 依旧延续着作者一贯秉持的极简、易用、高性能风格,只提供高性能的运行能力和易用的接口设计。把更多的可能性交给开发者,由那些富有创造力的 Java 开发者打造更优秀的 Http 作品。
更新内容
- 优化:升级 smart-socket 至 v1.5.7。
- bugfix:修复 WebSocketDefaultHandle 中的方法名单词拼写错误问题(感谢 @wujiawei0926)。
- bugfix:修复客户端 URI 后仅跟一个问号时的解析错位问题。
使用示例
1. Server 端
public class SimpleSmartHttp {
public static void main(String[] args) {
HttpBootstrap bootstrap = new HttpBootstrap();
// 普通http请求
bootstrap.pipeline().next(new HttpHandle() {
@Override
public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
response.write("hello world<br/>".getBytes());
}
});
// websocket请求
bootstrap.wsPipeline().next(new WebSocketDefaultHandle() {
@Override
public void handleTextMessage(WebSocketRequest request, WebSocketResponse response, String data) {
response.sendTextMessage("Hello World");
}
});
bootstrap.setPort(8080).start();
}
}
2. Client 端
public class HttpGetDemo {
public static void main(String[] args) {
HttpClient httpClient = new HttpClient("www.baidu.com", 80);
httpClient.connect();
httpClient.get("/")
.onSuccess(response -> System.out.println(response.body()))
.onFailure(Throwable::printStackTrace)
.send();
}
}
最后
如果觉得这个项目还不错,请给我们加个 Star。并且非常欢迎大家为这个项目贡献你的想法和代码,开源不易,且行且珍惜。
以上所述就是小编给大家介绍的《smart-http v1.1.2 发布,可编程的国产 Http 应用微内核》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- smart-http 1.1.0 发布,可编程的 Http 应用微内核
- smart-http 1.1.1 发布,可编程的国产 Http 应用微内核
- 一年回顾:测试可编程基础设施
- 程序媛大姐姐的可编程手表
- OpenGL(十一) 可编程管线 基础光照 的实现
- KubeVela 1.0:开启可编程式应用平台的未来
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Python Algorithms
Magnus Lie Hetland / Apress / 2010-11-24 / USD 49.99
Python Algorithms explains the Python approach to algorithm analysis and design. Written by Magnus Lie Hetland, author of Beginning Python, this book is sharply focused on classical algorithms, but it......一起来看看 《Python Algorithms》 这本书的介绍吧!