{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/133","labels_url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/133/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/133/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/133/events","html_url":"https://github.com/HaxeFoundation/haxelib/issues/133","id":31813657,"number":133,"title":"Part Downloads","user":{"login":"sirinath","id":637415,"avatar_url":"https://avatars.githubusercontent.com/u/637415?v=3","gravatar_id":"","url":"https://api.github.com/users/sirinath","html_url":"https://github.com/sirinath","followers_url":"https://api.github.com/users/sirinath/followers","following_url":"https://api.github.com/users/sirinath/following{/other_user}","gists_url":"https://api.github.com/users/sirinath/gists{/gist_id}","starred_url":"https://api.github.com/users/sirinath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirinath/subscriptions","organizations_url":"https://api.github.com/users/sirinath/orgs","repos_url":"https://api.github.com/users/sirinath/repos","events_url":"https://api.github.com/users/sirinath/events{/privacy}","received_events_url":"https://api.github.com/users/sirinath/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/HaxeFoundation/haxelib/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"back2dos","id":509501,"avatar_url":"https://avatars.githubusercontent.com/u/509501?v=3","gravatar_id":"","url":"https://api.github.com/users/back2dos","html_url":"https://github.com/back2dos","followers_url":"https://api.github.com/users/back2dos/followers","following_url":"https://api.github.com/users/back2dos/following{/other_user}","gists_url":"https://api.github.com/users/back2dos/gists{/gist_id}","starred_url":"https://api.github.com/users/back2dos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/back2dos/subscriptions","organizations_url":"https://api.github.com/users/back2dos/orgs","repos_url":"https://api.github.com/users/back2dos/repos","events_url":"https://api.github.com/users/back2dos/events{/privacy}","received_events_url":"https://api.github.com/users/back2dos/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2014-04-18T17:56:41Z","updated_at":"2015-12-22T22:08:47Z","closed_at":null,"body":"Is it possible to ensure partly downloaded files are not downloaded from the start. "},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/comments/166743707","html_url":"https://github.com/HaxeFoundation/haxelib/issues/133#issuecomment-166743707","issue_url":"https://api.github.com/repos/HaxeFoundation/haxelib/issues/133","id":166743707,"user":{"login":"nadako","id":49749,"avatar_url":"https://avatars.githubusercontent.com/u/49749?v=3","gravatar_id":"","url":"https://api.github.com/users/nadako","html_url":"https://github.com/nadako","followers_url":"https://api.github.com/users/nadako/followers","following_url":"https://api.github.com/users/nadako/following{/other_user}","gists_url":"https://api.github.com/users/nadako/gists{/gist_id}","starred_url":"https://api.github.com/users/nadako/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nadako/subscriptions","organizations_url":"https://api.github.com/users/nadako/orgs","repos_url":"https://api.github.com/users/nadako/repos","events_url":"https://api.github.com/users/nadako/events{/privacy}","received_events_url":"https://api.github.com/users/nadako/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T22:08:47Z","updated_at":"2015-12-22T22:08:47Z","body":"I have looked into it, and it seems quite easy to implement: we pass the `Range` header with `bytes=xxx-` value, where `xxx` is the current file size. And we open the file in the append mode (so `File.append`, not `File.write`.\r\n\r\nHere's a snipped to play with. I'm not a HTTP expect, but it looks okay to me. I did ctrl+c and restarted several times and still got full zip file downloaded. If noone sees any issues, I can add that to haxelib.\r\n```haxe\r\nimport haxe.io.Output;\r\nimport sys.io.File;\r\n\r\nclass Main {\r\n    static function main() {\r\n        var url = \"http://lib.haxe.org/files/3.0/lime-2,0,0-alpha,8.zip\";\r\n        var f = File.append(\"lime.zip\", true);\r\n        f.seek(0, SeekEnd);\r\n        var h = new haxe.Http(url);\r\n        var cur = f.tell();\r\n        if (cur > 0)\r\n            h.addHeader(\"range\", \"bytes=\"+cur + \"-\");\r\n        h.customRequest(false, new Progress(f, cur));\r\n    }\r\n}\r\n\r\nclass Progress extends Output {\r\n    var o : Output;\r\n    var cursize : Int;\r\n    var cur : Int;\r\n    var max : Int;\r\n\r\n    public function new(o, cursize) {\r\n        this.o = o;\r\n        this.cursize = cursize;\r\n        this.cur = cursize;\r\n    }\r\n\r\n    function report(n) {\r\n        cur += n;\r\n        if( max == null )\r\n            Sys.print(cur+\" bytes\\r\");\r\n        else\r\n            Sys.print(cur+\"/\"+max+\" (\"+Std.int((cur*100.0)/max)+\"%)\\r\");\r\n    }\r\n\r\n    public override function writeByte(c) {\r\n        o.writeByte(c);\r\n        report(1);\r\n    }\r\n\r\n    public override function writeBytes(s,p,l) {\r\n        var r = o.writeBytes(s,p,l);\r\n        report(r);\r\n        return r;\r\n    }\r\n\r\n    public override function close() {\r\n        super.close();\r\n        o.close();\r\n        Sys.println(\"Download complete : \"+cur+\" bytes\");\r\n    }\r\n\r\n    public override function prepare(m:Int) {\r\n        max = m + cursize;\r\n    }\r\n}\r\n```"}}