private void createTunnel() throws IOException, InterruptedException {
  while (true) {
    MockResponse connect=responseQueue.peek();
    if (!processOneRequest(raw.getInputStream(),raw.getOutputStream(),raw)) {
      throw new IllegalStateException("Tunnel without any CONNECT!");
    }
    if (connect.getSocketPolicy() == SocketPolicy.UPGRADE_TO_SSL_AT_END) {
      return;
    }
  }
}

private void createTunnel ( ) throws IOException , InterruptedException { while ( true ) { MockResponse connect = responseQueue . peek ( ) ; if ( ! processOneRequest ( raw . getInputStream ( ) , raw . getOutputStream ( ) , raw ) ) { throw new IllegalStateException ( "Tunnel without any CONNECT!" ) ; } if ( connect . getSocketPolicy ( ) == SocketPolicy . UPGRADE_TO_SSL_AT_END ) { return ; } } }
respond to connect requests until a switch_to_ssl_at_end response is dispatched .
