TS-2553: minor metalink refactoring

Reorder some functions so related functions are grouped together.
Rename some variables to more easily disambiguate them.
TS-2553: metalink: preserve the content length header

Copy the upstream nbytes (if known) downstream to preserve the
"Content-Length: ..." header.  In that case there will be a
TS_EVENT_VCONN_WRITE_COMPLETE event from downstream before ntodo
is zero, so write the digest to the cache in
transform_vconn_write_complete().  If the upstream nbytes isn't
known until the end of the content, update the downstream nbytes
and reenable it to get it to send a TS_EVENT_VCONN_WRITE_COMPLETE
event.  Fix some memory management.
TS-2553: metalink: avoid segfault in TSVIOReenable() if the client disconnected
TS-2553: metalink: small bug fixes and documentation updates

Drop TSVIOBufferGet() and test TSVIOReaderGet() instead. Improve
comments.
TS-2553 CHANGES