title: Indy Http Server with resume support
body: <p>I have written an indy http server, I want to serve file download with resume support. When I use IDM to download file, the download is single threaded:</p>
  
  <p><img src="https://i.stack.imgur.com/OgVi9.png" alt="enter image description here"></p>
  
  <p>Note that the <strong>Resume capability</strong> is <strong>Yes</strong>, but When I pause and resume the download, It starts form beginning.</p>
  
  <p>My Indy Http Server is as:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void __fastcall TfrmMain::httpServerCommandGet(TIdContext *AContext,
      TIdHTTPRequestInfo *ARequestInfo, TIdHTTPResponseInfo *AResponseInfo)
  {
      Beep(1000, 100);
      string fileName = ExtractFileDir(Application-&gt;ExeName) + ARequestInfo-&gt;Document;
      fileName = fileName.replace("/", "\\");
  
      TFileStream *stream = new TFileStream(fileName, fmOpenRead | fmShareDenyNone);
  
      int start = 0, end = 0;
      string range = ARequestInfo-&gt;Range;
      if(!range.empty())
      {
          int dash_pos = range.find("-");
          start = range.substr(0, dash_pos).intValue();
          end = range.substr(dash_pos + 1).intValue();
          if(end == 0) // Endless Range: start-
              end = stream-&gt;Size;
      }
      else
      {
          start = 0;
          end = stream-&gt;Size;
      }
      OutputDebugStringW(string("ctx=[] start=[] end=[]") &lt;&lt;
          IntToHex((int)AContext, 8) &lt;&lt; start &lt;&lt; end);
  
      stream-&gt;Seek((__int64)start, soBeginning);
      AResponseInfo-&gt;ContentStream = stream;
      AResponseInfo-&gt;FreeContentStream = true;
      AResponseInfo-&gt;ContentLength = stream-&gt;Size;
      if(!range.empty())
      {
          AResponseInfo-&gt;ContentRangeStart = start;
          AResponseInfo-&gt;ContentRangeEnd = end;
          AResponseInfo-&gt;ResponseNo = 206;
          AResponseInfo-&gt;ContentRangeInstanceLength = end + 1;
          AResponseInfo-&gt;ContentLength = end - start + 1;
          AResponseInfo-&gt;AcceptRanges = "bytes";
      }
      AResponseInfo-&gt;WriteHeader();
      AResponseInfo-&gt;WriteContent();
  }
  </code></pre>
  
  <p>any help would be appreciated.</p>