private ImapConnection writeRequest(final byte[] payload) throws IOException { ImapConnection conn = mConnection; if (conn == null) throw new IOException("proxy connection already closed"); // proxy the request over to the remote server OutputStream remote = conn.getOutputStream(); if (remote == null) { dropConnection(); throw new IOException("proxy connection already closed"); } remote.write(payload); remote.flush(); return conn; }