我已经设置了一个HttpServer
响应端口 80 上的请求,但它似乎只适用于localhost
和127.0.0.1
我需要处理来自机器外部 IP、“.local”或任何其他方式来寻址设备的请求。
相反,我得到“421(误导请求)”和“不权威”。
HttpServer server = ServerBootstrap.bootstrap()
.setListenerPort(80)
.register("/*", www)
.create();
server.start();
我也尝试过:
.setLocalAddress(new InetSocketAddress(0).getAddress())
我正在使用 httpcomponents-core 5.1 并基于例如: https ://github.com/apache/httpcomponents-core/blob/5.1.x/httpcore5/src/test/java/org/apache/hc/core5 /http/examples/ClassicFileServerExample.java
我已经通读了源代码,可以看到哪里出了问题,org.apache.hc.core5.http.protocol.RequestHandlerRegistry<T>
但是看不到如何避免这种陷阱的示例。