设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

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

2019-11-28 16:55| 发布者: joejoe0332| 查看: 444| 评论: 0|原作者: oschina|来自: oschina

摘要: smart-http 是一款比较简易的 http 服务器,其通信内核采用了smart-socket最新版v1.4.6。 也正因使用了 smart-socket,该服务器的性能表现还是非常不错的,在本人的4核CPU下能跑出 78W+的 qps。 smart-socket 的每次 ...

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还处于起步阶段,只要你足够优秀便可引导它的发展路线,感兴趣的欢迎入坑。


酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部