smart-http 1.0.18 发布,轻量级的国产 HTTP 服务器

栏目: 软件资讯 · 发布时间: 4年前

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

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

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

更新内容

  1. Http 解码算法可读性优化,性能小幅优化。
  2. 开放抽象类 Handle,兼容Kotlin。
  3. Response 支持移除 header 值。
  4. 添加 smart-http 启动 banner,支持开关控制。
  5. 修复 websocket 粘包场景下的掩码解析 bug,感谢网友:岁月最磨人 反馈。
  6. WebSocketRequest 新增接口获取本地/远程地址:getRemoteAddress、getLocalAddress

快速体验

  1. 在您的Maven工程中引入smart-http依赖。
    <dependency>
        <groupId>org.smartboot.http</groupId>
        <artifactId>smart-http-server</artifactId>
        <version>1.0.18</version>
    </dependency>

     

  2. 拷贝以下代码并启动。
    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();
        }
    }

     

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

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

福利时刻:基于 smart-http 实现的 Servlet 容器,也可能是国内首款自研的 Servlet 容器:smart-servlet  现已开源。该项目我们将尝试邀请社区中的开发者来参与共建,感兴趣的朋友欢迎加入我们,一起做一件牛逼的事。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Computer Age Statistical Inference

Computer Age Statistical Inference

Bradley Efron、Trevor Hastie / Cambridge University Press / 2016-7-21 / USD 74.99

The twenty-first century has seen a breathtaking expansion of statistical methodology, both in scope and in influence. 'Big data', 'data science', and 'machine learning' have become familiar terms in ......一起来看看 《Computer Age Statistical Inference》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具