javax.servlet.http.WebConnection Java Examples

The following examples show how to use javax.servlet.http.WebConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void init(WebConnection connection) {
    ServletInputStream sis;
    ServletOutputStream sos;

    try {
        sis = connection.getInputStream();
        sos = connection.getOutputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }

    EchoListener echoListener = new EchoListener(sis, sos);
    sis.setReadListener(echoListener);
    sos.setWriteListener(echoListener);
}
 
Example #2
Source File: PingUpgradeServlet.java    From sample.daytrader7 with Apache License 2.0 6 votes vote down vote up
@Override
public void init(final WebConnection wc) {
    Listener listener = null;
    try {
        listener = new Listener(wc);
      
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
      
    try {
        
        if (Log.doTrace()) {
            Log.trace("PingUpgradeServlet$Handler.init() -- Initializing Handler");
        }
  
        // flush headers if any
        wc.getOutputStream().flush();
        wc.getInputStream().setReadListener(listener);

    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example #3
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {

    try (ServletInputStream sis = connection.getInputStream();
         ServletOutputStream sos = connection.getOutputStream()){
        byte[] buffer = new byte[8192];
        int read;
        while ((read = sis.read(buffer)) >= 0) {
            sos.write(buffer, 0, read);
            sos.flush();
        }
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
}
 
Example #4
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {
    ServletInputStream sis;
    try {
        sis = connection.getInputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
    sis.setReadListener(null);
}
 
Example #5
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {
    ServletOutputStream sos;
    try {
        sos = connection.getOutputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
    sos.setWriteListener(null);
}
 
Example #6
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {
    ServletInputStream sis;
    ServletOutputStream sos;
    try {
        sis = connection.getInputStream();
        sos = connection.getOutputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
    sos.setWriteListener(new NoOpWriteListener());
    ReadListener rl = new NoOpReadListener();
    sis.setReadListener(rl);
    sis.setReadListener(rl);
}
 
Example #7
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {
    ServletInputStream sis;
    ServletOutputStream sos;
    try {
        sis = connection.getInputStream();
        sos = connection.getOutputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }
    sis.setReadListener(new NoOpReadListener());
    WriteListener wl = new NoOpWriteListener();
    sos.setWriteListener(wl);
    sos.setWriteListener(wl);
}
 
Example #8
Source File: TestUpgrade.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void init(WebConnection connection) {

    try {
        sis = connection.getInputStream();
        sos = connection.getOutputStream();
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }

    sis.setReadListener(new NoOpReadListener());
    sos.setWriteListener(new FixedResponseWriteListener());
}
 
Example #9
Source File: AsyncUpgradeServlet.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
@Override
public void init(final WebConnection wc) {
    Listener listener = new Listener(wc);
    try {
        //we have to set the write listener before the read listener
        //otherwise the output stream could be written to before it is
        //in async mode
        wc.getOutputStream().setWriteListener(listener);
        wc.getInputStream().setReadListener(listener);
    } catch (IOException e) {
        UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
    }
}
 
Example #10
Source File: WsHttpUpgradeHandler.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void init(WebConnection connection) {
    if (ep == null) {
        throw new IllegalStateException(
                sm.getString("wsHttpUpgradeHandler.noPreInit"));
    }

    String httpSessionId = null;
    Object session = handshakeRequest.getHttpSession();
    if (session != null ) {
        httpSessionId = ((HttpSession) session).getId();
    }

    // Need to call onOpen using the web application's class loader
    // Create the frame using the application's class loader so it can pick
    // up application specific config from the ServerContainerImpl
    Thread t = Thread.currentThread();
    ClassLoader cl = t.getContextClassLoader();
    t.setContextClassLoader(applicationClassLoader);
    try {
        wsRemoteEndpointServer = new WsRemoteEndpointImplServer(socketWrapper, webSocketContainer);
        wsSession = new WsSession(ep, wsRemoteEndpointServer,
                webSocketContainer, handshakeRequest.getRequestURI(),
                handshakeRequest.getParameterMap(),
                handshakeRequest.getQueryString(),
                handshakeRequest.getUserPrincipal(), httpSessionId,
                negotiatedExtensions, subProtocol, pathParameters, secure,
                serverEndpointConfig);
        wsFrame = new WsFrameServer(socketWrapper, wsSession, transformation,
                applicationClassLoader);
        // WsFrame adds the necessary final transformations. Copy the
        // completed transformation chain to the remote end point.
        wsRemoteEndpointServer.setTransformation(wsFrame.getTransformation());
        ep.onOpen(wsSession, serverEndpointConfig);
        webSocketContainer.registerSession(serverEndpointConfig.getPath(), wsSession);
    } catch (DeploymentException e) {
        throw new IllegalArgumentException(e);
    } finally {
        t.setContextClassLoader(cl);
    }
}
 
Example #11
Source File: AsyncUpgradeServlet.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
private Listener(final WebConnection connection) {
    this.connection = connection;
}
 
Example #12
Source File: DefaultHttpServletRequestTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void init(WebConnection wc) {
}
 
Example #13
Source File: DefaultHttpServletRequestTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void init(WebConnection wc) {
}
 
Example #14
Source File: NanoRequestTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void init(WebConnection webConnection) {
}
 
Example #15
Source File: ImmediateCloseConnection.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void init(WebConnection wc) {
    close(wc::getInputStream);
    close(wc::getOutputStream);
}
 
Example #16
Source File: PingUpgradeServlet.java    From sample.daytrader7 with Apache License 2.0 4 votes vote down vote up
private Listener(final WebConnection connection) throws IOException  {
    this.connection = connection;
    this.input = connection.getInputStream();
    this.output = connection.getOutputStream();
}