http by default allows partial request, so browser/curl can resume download when using range header
to see if server allows partial transmission of data :
https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
BASH
curl -I http://i.imgur.com/z4d4kWk.jpg
HTTP
HTTP/1.1 200 OK
…
Accept-Ranges: bytes
Content-Length: 146515If server response Accept-Ranges: byte, then server accepts partial
For GO gin, c.FileAttachement enable or r.static at router level enables range
https://pkg.go.dev/github.com/gin-gonic/gin#Context.Filefunc (c *Context) FileAttachment(filepath, filename string)for curl you can request rangehttps://everything.curl.dev/http/ranges.htmlFor browser set up for resumable download visit:https://stackoverflow.com/questions/38200426/detecting-when-the-browser-has-requested-to-download-a-fileEach time you will get some content and http response 206The HTTP206 Partial Contentsuccess status response code indicates that the request has succeeded and the body contains the requested ranges of data, as described in theRangeheader of the request.https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206curl -r 0-199 http://example.comOr everything in the file starting from index 200:
curl -r 200- http://example.comGet 200 bytes from index 0 and 200 bytes from index 1000:
curl -r 0-199,1000-1199 http://example.com/
No comments:
Post a Comment