[Solved] lNet pause download and ranged request lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lancilnove · 2012-03-19 16:52 Hello, I need to download big files, isos over 2GB in size. I tried Indy, synapse, curl, interntettools, wininet. My choice is: lNet. I love it. It's fast (the fastest), lightweight and user friendly. Unfortunately it lacks something I need: ranged request. To tell the truth it has the properties RangeStart and RangeEnd but, alas, they don't work. When these properties are set, nothing happens. Without this feature you can't pause/resume a download. You can't accelerate a download by segmenting it in parallel tasks (like flashget). In a previous post Almindor wrote, answering a similar question, 'I must admit this area of lNet is outside of my expertise (http was done by Micha Nelissen [neli]). I'll try to figure out if this is a bug or something is missing on your end.' Now, is this a bug? Is something missing on my end? ---------------------------------------------------------------------- Almindor · 2012-04-13 22:18 I'm afraid this might be a bug. I wrote lNet, but the HTTP part code was done by Micha Nelissen and I'm afraid my knowledge of it is a bit limited. I've also fallen out of things with FPC lately (am working on Android atm. so yeah.. java) which makes this even more difficult to fix. The good news is, I'm currently sort of on a long vacation so I might be able to get back into things. I'll try to get Micha to look at this too. ---------------------------------------------------------------------- Almindor · 2012-04-14 09:03 Micha thinks it should work: not really, it should work?    hasRangeStart := TLHTTPClient(FCreator).RangeStart <> high(qword);    hasRangeEnd := TLHTTPClient(FCreator).RangeEnd <> high(qword); is the code to include it    if hasRangeStart or hasRangeEnd then .... just set it before sending the request afaics ---------------------------------------------------------------------- lancilnove · 2012-04-16 18:12 Ciao Alminder. Thanks for having found the time to answer. lNet is a nice little creature that deserves proper attention. I think that The lines in lhttp.pp you're referring to are working fine. According to Http Analyzer, a very useful tool, the header is ok (the server returns 206 as it should be for ranged requests). It is as if a 206 answer triggered a disconnect event in the client. lNet can send a range request but can't handle a 206 answer. Look at these lines in lhttp.pp, 206 is not even contemplated: Code: [Select]  HTTPStatusCodes: array[TLHTTPStatus] of dword =     (0, 200, 204, 301, 302, 304, 400, 403, 404, 412, 414, 500, 501, 405);   HTTPTexts: array[TLHTTPStatus] of string =     ('', 'OK', 'No Content', 'Moved Permanently', 'Found', 'Not Modified', 'Bad Request', 'Forbidden',      'Not Found', 'Precondition Failed', 'Request Too Long', 'Internal Error',      'Method Not Implemented', 'Method Not Allowed'); Here's a sample of the code I used: Code: [Select]  HTTPClient.Host := Host;   HTTPClient.Port := Port;   HTTPClient.URI := URI;   HTTPClient.Method:= hmGet;   [...]   HTTPClient.RangeStart := 10;   HTTPClient.RangeEnd := 100;   //HTTPClient.AddExtraHeader('Range: bytes=start-end');   HTTPClient.SendRequest; ---------------------------------------------------------------------- lancilnove · 2012-04-23 10:30 In 'The Fifth Element' Zorg, quoting Henry Wadsworth Longfellow or Charles Spurgeon, says "If you want something done, do it yourself. Yep!" Well, I carefully perused lhttp.pp code and added a few lines. RangeStart and RangeEnd properties are now ok. lNet works fine with Range requests! This evening I'm going to test AddExtraHeader property. I'm very happy