prepare for range download

rearrange read/seek code, no functionality change
enable seeking on SX side