Previously we read too much data from our input, and then used the
unused portion as an initial state of a buffer for handling
subsequent data. Yuck! Instead we can just use an AsyncBufRead and
only read the parts we want.
This code takes some pains to never read too much data: I'd rather
just "read until the first CRLF" or have some kind of pushback
mechanism. But for now it's probably fine.
This is fairly ugly and I think I'll need to mess around with the
feature configuration a while until we get something that's pleasant
to develop with. This still seems like a good idea, though, since
we _will_ need to be executor-agnostic in the end, or we'll have no
way to handle wasm or embedded environments.
Later down the road, we'll probably want to use futures::Executor or
futures::Spawn more than having global entry points in
tor_rtcompat. That would probably make our feature story simpler.
Tokio is the default now, since tokio seems to be more heavily used
for performance-critical stuff.
This patch breaks tests; the next one will fix them, albeit
questionably.
This adds two timeouts in total: one for sending begin, and getting
headers, and one for getting the rest of the data.
These timeouts are way too long right now, but at least the code is
there.
Some requests are still useful when we get only a partial response
-- like those where we're asking for a bunch of documents at once.
For those, we should return any nonempty partial result.
It can send a GET request on a circuit, get an answer, and
decompress it with zlib.
It will need documentation and tests eventually, as well as serious
refactoring.