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

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

内容简介:smart-http 是一款比较简易的 http服务器,其通信内核采用了异步非阻塞通信框架 smart-socket。 更新内容 升级smart-socket至最新版:1.4.5。 优化Http协议解析算法以获得更好的性能表现(依旧模仿nginx解码思路)...

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


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

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

Haskell Programming from first principles

Haskell Programming from first principles

Christopher Allen、Julie Moronuki / 2015 / USD 59.00

I am writing this book because I had a hard time learning Haskell. It doesn't have to be that way. I've spent the last couple years actively teaching Haskell online and in person. Along the way, I ......一起来看看 《Haskell Programming from first principles》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试