/** * Respond to CONNECT requests until a SWITCH_TO_SSL_AT_END response is * dispatched. */ private void createTunnel() throws IOException, InterruptedException { BufferedSource source = Okio.buffer(Okio.source(raw)); BufferedSink sink = Okio.buffer(Okio.sink(raw)); while (true) { SocketPolicy socketPolicy = dispatcher.peek().getSocketPolicy(); if (!processOneRequest(raw, source, sink)) { throw new IllegalStateException("Tunnel without any CONNECT!"); } if (socketPolicy == UPGRADE_TO_SSL_AT_END) return; } }
BufferedSink sink = Okio.buffer(Okio.sink(socket)); while (processOneRequest(socket, source, sink)) {