@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); } }
@Override public void init(WebConnection wc) { try (ServletInputStream input = wc.getInputStream(); ServletOutputStream output = wc.getOutputStream();) { output.write(("upgrade" + CRLF).getBytes()); output.write(("received" + CRLF).getBytes()); output.write("END".getBytes()); } catch (IOException ex) { } }
@Override public void init(WebConnection wc) { try (ServletInputStream input = wc.getInputStream(); ServletOutputStream output = wc.getOutputStream();) { } catch (IOException ex) { } }
@Override public void init(WebConnection wc) { close(wc::getInputStream); close(wc::getOutputStream); }
private Listener(final WebConnection connection) throws IOException { this.connection = connection; this.input = connection.getInputStream(); this.output = connection.getOutputStream(); }