private void flushOnSSLHandshakeComplete() throws IOException {
final FilterChain filterChain = context.getFilterChain();
final int idx = filterChain.indexOfType(SSLFilter.class);
assert (idx != -1);
final SSLFilter filter = (SSLFilter) filterChain.get(idx);
final Connection c = context.getConnection();
filter.addHandshakeListener(new SSLBaseFilter.HandshakeListener() {
public void onStart(Connection connection) {
}
public void onComplete(Connection connection) {
if (c.equals(connection)) {
filter.removeHandshakeListener(this);
try {
feeder.flush();
} catch (IOException ioe) {
throwError(ioe);
}
}
}
});
filter.handshake(context.getConnection(), null);
}