smart-http 1.0.12 发布,7 行代码便可运行的 HTTP 服务器

smart-http 是一款比较简易的 http 服务器,其通信内核采用了 smart-socket 最新版v1.4.6

也正因使用了 smart-socket,该服务器的性能表现还是非常不错的,在本人的4核CPU下能跑出 78W+的 qps。

smart-socket 的每次性能测试都是基于该服务器进行的,相信 smart-http 的表现不会让您失望的。

更新内容

  1. 升级smart-socket至最新版:1.4.6,提升服务性能。

  2. 优化Http协议解析算法对于 Post 请求的处理。

  3. 示例代码与核心 http 功能进行模块拆分,工程结构更合理。
  4. 精简依赖,打包后的 smart-http-server 模块仅 88KB,所有依赖总共也只有 171KB。
  5. 修复一些 PMD、checkstyle 扫描出的问题。
  6. 调整 HttpRequest 接口设计,适配 commons-fileupload 提供文件上传解析支持。

快速体验

  1. 在您的Maven工程中引入smart-http依赖。
    <dependency>
        <groupId>org.smartboot.http</groupId>
        <artifactId>smart-http-server</artifactId>
        <version>1.0.12</version>
    </dependency>
  2. 拷贝以下代码并启动。
    public class SimpleSmartHttp {
        public static void main(String[] args) {
            HttpBootstrap bootstrap = new HttpBootstrap();
            bootstrap.pipeline().next(new HttpHandle() {
                public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
                    response.write("hello world".getBytes());
                }
            });
            bootstrap.setPort(8080).start();
        }
    }
  3. 浏览器访问:http://localhost:8080/

最后

smart-http还处于起步阶段,只要你足够优秀便可引导它的发展路线,感兴趣的欢迎入坑。

猜你喜欢

转载自www.oschina.net/news/111679/smart-http-1-0-12-released