Servlet service() method not getting called for CONNECT requests

后端 未结 4 942
陌清茗
陌清茗 2021-01-25 22:39

I am trying to write a forward proxy in Jetty using Servlet 3.0.

I\'ve a simple code-

public class testServlet          


        
4条回答
  •  天命终不由人
    2021-01-25 23:05

    You're doing this wrong. The Servlet API and framework is for writing servlets, i.e. endpoints. Not for writing HTTP proxies. HTTP proxies are fundamentally very simple things that understand one command, CONNECT, and then just copy bytes in both directions. Even if you could make this work as a servlet, which you almost certainly can't, the performance impact would be atrocious, as the container would read the entire request before calling you, and probably buffer the response as well. You don't want all that added latency.

提交回复
热议问题