Connection::Connection(Stream::ptr stream) : m_stream(stream) { MORDOR_ASSERT(stream); MORDOR_ASSERT(stream->supportsRead()); MORDOR_ASSERT(stream->supportsWrite()); if (!stream->supportsUnread() || !stream->supportsFind()) { BufferedStream *buffered = new BufferedStream(stream); buffered->allowPartialReads(true); m_stream.reset(buffered); } }