Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能得到原始请求com.sun.net.httpserver.HttpExchange?
com.sun.net.httpserver.HttpExchange
我HttpServer用来做代理,所以我想获取原始的http请求并将其发送到原始主机。
HttpServer
HttpExchangeAPI 不支持这一点。您(当然)可以自由地创建自己的类,该类HttpExchange可以随心所欲地扩展和实现其方法。(类实际上只是一组抽象方法。)
HttpExchange
唯一的另一种可能性是查看HttpExchangeSun/Oracle 代码库中的一些现有实现。
我对如何有效实现的直觉HttpExchange是通用实现不会捕获原始请求消息。
即使这样做了,您也必须“四处寻找”您的代码不应该直接使用的类的内部结构。由于显而易见的原因,这是一个坏主意。