🎉smart-http v1.1.21 版本发布

1、smart-http 简介

smart-http 是一款可编程式HTTP应用微内核。它是目前市面上为数不多即能严格准守 RFC2616 规范,又兼顾卓越性能的 Http 服务器。

smart-http 完全建立在自研的通信框架 smart-socket 之上,使其有着纯正的国产化血统。该项目对标的是 nginx,高性能、轻量化是其追求和坚持的目标。

严格意义上 smart-http 算不上是一个框架,它更像一个工具类库。开发人员可以基于它封装出契合特定场景的应用框架或解决方案。

模块介绍

模块 说明 代码量
smart-http-common 基础通用模块,包括枚举、日志、工具类 2300+
smart-http-client HTTP Client编解码和响应式编程设计 1400+
smart-http-server HTTP Server和WebSocket的编解码和应用层接口设计 2700+
smart-http-restful 基于smart-http-server的简易版 MVC模块(实验性 380+
smart-http-test 单测模块 1200+

2、 版本更新

Maven

<dependency>
    <groupId>org.smartboot.http</groupId>
    <artifactId>smart-http-server</artifactId>
    <version>1.1.21</version>
</dependency>

<dependency>
    <groupId>org.smartboot.http</groupId>
    <artifactId>smart-http-client</artifactId>
    <version>1.1.21</version>
</dependency>

本次更新内容

  1. httpClient 支持链路复用。

  2. 重构httpClient接口设计,改进编码体验。

  3. websocket支持大消息体解码。

  4. websocket支持继续帧解码。

  5. smart-socket版本号调整为:1.5.24

  6. 提升restful模块稳定性。

  7. 修复静态资源文件缓存时间精度问题。

  8. 修复特定情况下出现多个Content-Length的问题。

  9. 支持链路复用情况下普通Http请求升级为Websocket。

  10. 补充单侧用例。

3、快速上手

3.1 HTTP 服务端

publicclass SimpleSmartHttp {
    public static void main(String[] args) {
        HttpBootstrap bootstrap = new HttpBootstrap();
        bootstrap.httpHandler(new HttpServerHandler() {
            @Override
            public void handle(HttpRequest request, HttpResponse response) throws IOException {
                response.write("hello smart-http<br/>".getBytes());
            }
        }).setPort(8080).start();
    }
}

3.2 WebSocket 服务端

publicclass WebSocketDemo {
    public static void main(String[] args) {
        //1. 实例化路由Handle
        WebSocketRouteHandler routeHandle = new WebSocketRouteHandler();

        //2. 指定路由规则以及请求的处理实现
        routeHandle.route("/", new WebSocketDefaultHandler() {
            @Override
            public void handleTextMessage(WebSocketRequest request, WebSocketResponse response, String data) {
                response.sendTextMessage("接受到客户端消息:" + data);
            }
        });

        // 3. 启动服务
        HttpBootstrap bootstrap = new HttpBootstrap();
        bootstrap.webSocketHandler(routeHandle);
        bootstrap.start();
    }
}

3.3 Http客户端

publicclass HttpGetDemo {
    public static void main(String[] args) {
        HttpClient httpClient = new HttpClient("www.baidu.com", 80);
        httpClient.get("/").header().keepalive(false).done()
                .onSuccess(response -> System.out.println(response.body()))
                .onFailure(Throwable::printStackTrace)
                .done();
    }
}

3.4 Restful

<dependency>
    <groupId>org.smartboot.http</groupId>
    <artifactId>smart-http-restful</artifactId>
    <version>${smarthttp.version}</version>
</dependency>
@Controller
publicclass RestfulDemo {

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String helloworld() {
        return"hello world";
    }

    public static void main(String[] args) throws Exception {
        RestfulBootstrap bootstrap = RestfulBootstrap.getInstance().controller(RestfulDemo.class);
        bootstrap.bootstrap().setPort(8080).start();
    }
}

smartboot开源组织,一个容易被误认为是在“重复造轮子”的低调组织。曾获得 2020 年度 OSC 中国开源项目「优秀 Gitee 组织 」荣誉。

该组织内的明星项目包括:

  • smart-socket
    历时5年精炼出2千多行代码,轻松实现百万级长连接的 AIO 通信框架。

  • smart-http
    基于 smart-socket 实现的 HTTP/1.1 web服务。

  • smart-servlet
    基于 smart-http 实现的 Servlet 3.1 容器服务。

  • smart-broker
    基于 smart-socket 实现的 MQTT 3.1.1/5.0 Broker 服务。

  • smart-flow
    一款具备可观测性的轻量级业务编排框架。

组织地址:?https://smartboot.tech/
代码仓库:?https://gitee.com/smartboot

优秀的个人博客,低调大师

微信关注我们

原文链接:https://www.oschina.net/news/230106/smart-http-1-1-21-released

转载内容版权归作者及来源网站所有!

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

相关文章

发表评论

资源下载

更多资源
优质分享Android(本站安卓app)

优质分享Android(本站安卓app)

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario,低调大师唯一一个Java游戏作品

Mario,低调大师唯一一个Java游戏作品

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Oracle Database,又名Oracle RDBMS

Oracle Database,又名Oracle RDBMS

Oracle Database,又名Oracle RDBMS,或简称Oracle。是甲骨文公司的一款关系数据库管理系统。它是在数据库领域一直处于领先地位的产品。可以说Oracle数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的、适应高吞吐量的数据库方案。

Java Development Kit(Java开发工具)

Java Development Kit(Java开发工具)

JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。