Correct documentation.

Options are traditionally above the @param block as it results in easier
to read API docs.
Fix downloading Ranges in files.

Correctly handle ranges that don't terminate at the end of the file.
Also reject invalid ranges as described in RFC-2616.

Thanks to Kim Biesbjerg for the initial patch.

Fixes #3914