virtual sf::Error read (const ds::Range & range, ByteArray & dst) { LockGuard guard (mMutex); ds::Range realRange = ds::Range (range.from - mPosition, range.to - mPosition); if (realRange.from != 0) return error::NotSupported; // no seeking ByteArrayPtr data = mChannel->read (range.to); if (data) { dst.swap (*data); } if (!data || data->empty()){ mReady = false; } mPosition+=dst.size(); return mChannel->error(); }
void HttpConnectionManager::onChannelChange (AsyncOpId id) { PendingConnectionOp * op; getReadyAsyncOp (id, PendingConnection, &op); if (!op) return; ByteArrayPtr all = op->connection->channel->read(); if (all && !all->empty()){ Log (LogInfo) << LOGID << "Recv in pending connection: " << *all << std::endl; op->connection->inputBuffer.append(*all); } Error e = op->connection->channel->error(); if (e) { // adieu Log (LogInfo) << LOGID << "Closing channel to " << op->connection->host << " as channel reported error: " << toString (e) << std::endl; xcall (abind (&throwAway, op->connection)); removeFromPendingConnections (op); delete op; return; } // data ready? nobody knows, add it again... addAsyncOp (op); }