java http长连接_「开源资讯」smart-http 1.0.15 发布,轻量级的国产 HTTP 服务器

smart-http简介

smart-http 是一款采用 Java 语言编写的 Http 服务器,有别于业界知名的 Web容器:Tomcat、Undertow,smart-http 并不支持 Servlet 规范,但对于 Http 服务器所需的各项能力,它都具备。

smart-http 天生就是异步非阻塞的 I/O 模型,因为其通信内核采用了 smart-socket。所以无论是性能还是稳定性,都是非常出色的。

5293c9235bedd2d2a8c2fbcee49a4e4e.png
f98483fab5095bfcca37a05c5c5379a2.png

更新内容

优化Http Request的流操作修复长连接状态下的个别字段未重置问题。支持Http1.0协议的长连接。增加畸形报文攻击防范策略。WebSocketResponse 新增 flush 接口。升级 smart-socket 至 1.4.12。

快速体验

第一步:在您的Maven工程中引入smart-http依赖。

org.smartboot.http    smart-http-server    1.0.15

第二步:拷贝以下代码并启动。

public class SimpleSmartHttp {

public static void main(String[] args) {

HttpBootstrap bootstrap = new HttpBootstrap();

//http消息

bootstrap.pipeline().next(new HttpHandle() {

public void doHandle(HttpRequest request, HttpResponse response) throws IOException {

response.write("hello world".getBytes());

}

});

//websocket消息

bootstrap.wsPipeline().next(new WebSocketHandle() {

public void doHandle(WebSocketRequest request, WebSocketResponse response) throws IOException {

response.sendTextMessage("hello world");

}

});

bootstrap.setPort(8080).start();

}

}

第三步:浏览器访问:http://localhost:8080/ 或采用ws客户端请求ws://127.0.0.1:8080

更多文档请访问:https://smartboot.gitee.io/book/smart-http/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值