使用反应器提供静态内容
Serving static content with reactor
我想让我的反应器服务公开一些带有状态信息的静态 html。
projectreactor.io 为此使用 reactor-netty,它非常适合为单个独立文件提供服务:
HttpServer http = HttpServer.create("0.0.0.0", 8100);
http.directory("/static", someLocalPath);
http.start().subscribe();
但是,一旦 html 引用另一个文件,对引用文件的请求就会在浏览器中保持挂起状态,并且永远不会完成。
例如。具有以下内容的 index.html:
<html><body>
<img src="http://localhost:8100/static/small.jpg" />
</body></html>
此处浏览器显示 index.html 的状态 200 和 small.jpg
的状态 "pending"
直接请求 small.jpg 没有问题。
我做错了什么?
这是 reactor-netty 0.5.1.RELEASE 中的一个错误。
它在 0.5.2.RELEASE.
中固定
感谢 Simon Baslé @reactor
我想让我的反应器服务公开一些带有状态信息的静态 html。 projectreactor.io 为此使用 reactor-netty,它非常适合为单个独立文件提供服务:
HttpServer http = HttpServer.create("0.0.0.0", 8100);
http.directory("/static", someLocalPath);
http.start().subscribe();
但是,一旦 html 引用另一个文件,对引用文件的请求就会在浏览器中保持挂起状态,并且永远不会完成。 例如。具有以下内容的 index.html:
<html><body>
<img src="http://localhost:8100/static/small.jpg" />
</body></html>
此处浏览器显示 index.html 的状态 200 和 small.jpg
的状态 "pending"直接请求 small.jpg 没有问题。
我做错了什么?
这是 reactor-netty 0.5.1.RELEASE 中的一个错误。
它在 0.5.2.RELEASE.
感谢 Simon Baslé @reactor