smart-http 是一款比较简易的 http服务器,其通信内核采用了异步非阻塞通信框架 smart-socket。
更新内容
-
升级smart-socket至最新版:1.4.5。
-
优化Http协议解析算法以获得更好的性能表现(依旧模仿nginx解码思路)。
- 提供对HEAD请求的支持。
- 节省解码期间不必要的内存开销。
- HttpRequest新增接口:getRemoteAddr、getRemoteHost。
- 代码重构,消除一些不合理的设计。
快速体验
- 在您的Maven工程中引入smart-http依赖。
<dependency> <groupId>org.smartboot.http</groupId> <artifactId>smart-http-server</artifactId> <version>1.0.11</version> </dependency>
- 拷贝以下代码并启动。
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(); } }
- 浏览器访问:http://localhost:8080/
最后
smart-http还处于起步阶段,只要你足够优秀便可引导它的发展路线,感兴趣的欢迎入坑。