[英]HttpHandler fails to handle http requests
I'm trying to build https proxy server using com.sun.net.httpServer.* library. 我正在尝试使用com.sun.net.httpServer。*库构建https代理服务器。 when I'm defining the server context as follows: 当我如下定义服务器上下文时:
httpServer.createContext("/test", new MyHandler());
and I open from a browser the url: " https://localhost:443/test " it works as expected, but when the server context is defined this way: 并且我从浏览器中打开了URL:“ https:// localhost:443 / test ”,它可以按预期工作,但是以这种方式定义服务器上下文时:
httpServer.createContext("/", new MyHandler());
I notice that my handler is not being used when I enter a URL like: " https://www.google.co.il/ " 我注意到当我输入类似“ https://www.google.co.il/ ”的URL时,没有使用我的处理程序。
What am I missing? 我想念什么?
This line will only change the context path, not the server URL. 该行将仅更改上下文路径,而不更改服务器URL。
httpServer.createContext("/", new MyHandler());
So for this context, you will get a response at this URL - " https://localhost:443/ ". 因此,对于这种情况,您将在以下URL处获得响应-“ https:// localhost:443 / ”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.