Am using golang as a programming tool of choice.
What i wanted to write is a program that downloads large files with resume support utilising range requests in the http headers something similar to aria2c.
To do that you should study the part 14.16 — Content-Range
— of the RFC
document describing the HTTP/1.1
protocol and then apply that knowledge to manipulate the set of HTTP headers sent when the client request is executed — see the documentation and examples there.
To calculate the range to request, to continue downloading, you should get the current file's size. This can be found in the results returned by the Stat()
function which can be called on an opened file — *os.File
returned by a call to os.Open()
.
You should open your file in append mode and then use something like io.Copy()
to stream the data from the Body
HTTP response member to the file object.
Do your own research on how to read data from HTTP responses in Go — they are abundant on the Internet.