Servlet service() method not getting called for CONNECT requests

后端 未结 4 898
陌清茗
陌清茗 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 22:44

    It is possible to deliver a CONNECT request to a Servlet service method, but it is ultimately futile to do so because it is impossible to handle a CONNECT inside a servlet. You don't really have access to the raw IO streams, only the HTTP content of the request/response. You can almost make his work, but never efficiently (no async IO etc.) So ultimately you will end up falling back to Jetty APIs anyway.

    Also, why not just build on the support already provided by Jetty:

    http://download.eclipse.org/jetty/stable-9/xref/org/eclipse/jetty/proxy/ConnectHandler.html http://download.eclipse.org/jetty/stable-9/xref/org/eclipse/jetty/proxy/ProxyServlet.html

提交回复
热议问题