您现在的位置是:首页 > 文章详情

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

日期:2019-11-16点击:440

smart-http 是一款比较简易的 http服务器,其通信内核采用了异步非阻塞通信框架 smart-socket。

更新内容

  1. 升级smart-socket至最新版:1.4.5。

  2. 优化Http协议解析算法以获得更好的性能表现(依旧模仿nginx解码思路)。

  3. 提供对HEAD请求的支持。
  4. 节省解码期间不必要的内存开销。
  5. HttpRequest新增接口:getRemoteAddr、getRemoteHost。
  6. 代码重构,消除一些不合理的设计。

快速体验

  1. 在您的Maven工程中引入smart-http依赖。
     <dependency> <groupId>org.smartboot.http</groupId> <artifactId>smart-http-server</artifactId> <version>1.0.11</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还处于起步阶段,只要你足够优秀便可引导它的发展路线,感兴趣的欢迎入坑。

原文链接:https://www.oschina.net/news/111379/smart-http-1-0-11-released
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章