Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3497016
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:19:10+00:00 2026-05-18T12:19:10+00:00

We are trying to write an update server for our software using the TIdHTTPServer

  • 0

We are trying to write an update server for our software using the TIdHTTPServer component. Currently we are serving an XML file that lists the available updates and their file versions etc.., when the client program finds a updated version it should start to download it using BITS.

Now this is where we have a problem, our programs are requesting the XML file and seeing there is an update available. It then creates a BITS job to download it, however BITS keeps reporting that the download failed. We can download the file using the same URL and IE/Firefox/Chrome.

so my question:

Is TIdHTTPServer compatible with BITS?

I ask this as I have discovered that there are these download requirements for bits to work.
HTTP Requirements for BITS Downloads

BITS supports HTTP and HTTPS downloads and uploads and requires that the server supports the HTTP/1.1 protocol. For downloads, the HTTP server’s Head method must return the file size and its Get method must support the Content-Range and Content-Length headers. As a result, BITS only transfers static file content and generates an error if you try to transfer dynamic content, unless the ASP, ISAPI, or CGI script supports the Content-Range and Content-Length headers.

BITS can use an HTTP/1.0 server as long as it meets the Head and Get method requirements.

To support downloading ranges of a file, the server must support the following requirements:

Allow MIME headers to include the standard Content-Range and Content-Type headers, plus a maximum of 180 bytes of other headers.
Allow a maximum of two CR/LFs between the HTTP headers and the first boundary string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:19:10+00:00Added an answer on May 18, 2026 at 12:19 pm

    So the answer to this question is:

    Yes TIdHTTPServer is Bits Compatible.

    But only if you are prepared to do the work yourself.

    As suggested by @Rob Kennedy and Myself it is possible to read the headers and send the data back using the requested ranges, one chunk at a time.

    Here is an example of what I am doing in the OnCommandGet event

    procedure TForm3.IdHTTPServer1CommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    var
      Ranges : TIdEntityRanges;
      DataChunk: TMemoryStream;
      ReqFile: TFileStream;
      ChunkLength: Int64;
      Directory, FileName: string;
    begin
      Directory := 'H:';
    
      case ARequestInfo.Ranges.Count of
      0:
        begin
          //serve file normally
        end;
      1:
        begin
          //serve range of bytes specified for file
    
          filename := Directory + ARequestInfo.Document;
    
          if FileExists(FileName) then
          begin
            ReqFile := TFileStream.Create(FileName, fmOpenRead);
            try
              ChunkLength := Succ(ARequestInfo.Ranges.Ranges[0].EndPos - ARequestInfo.Ranges.Ranges[0].StartPos);
    
              if ChunkLength > ReqFile.Size then
                ChunkLength := ReqFile.Size;
    
              DataChunk := TMemoryStream.Create;
              DataChunk.Posistion := ARequestInfo.Ranges.Ranges[0].StartPos;  
              DataChunk.CopyFrom(ReqFile, ChunkLength);
    
              AResponseInfo.ContentStream := DataChunk;
              AResponseInfo.ContentType := IdHTTPServer1.MIMETable.GetFileMIMEType(FileName);
              AResponseInfo.ContentRangeUnits := ARequestInfo.Ranges.Units;
              AResponseInfo.ContentRangeStart := ARequestInfo.Ranges.Ranges[0].StartPos;
              AResponseInfo.ContentRangeEnd := ARequestInfo.Ranges.Ranges[0].StartPos + Pred(ChunkLength);
              AResponseInfo.ContentRangeInstanceLength := ReqFile.Size;
              AResponseInfo.ResponseNo := 206;
            finally
              ReqFile.Free;
            end;
          end
          else
            AResponseInfo.ResponseNo := 404;
    
        end
      else
        begin
          //serve the file as multipart/byteranges
        end;
      end;
    
    end;
    

    This is by no means finished but it shows the basics of responding to the range requests from BITS. Most importantly it works.

    Any comments on the code would be appreciated, constructive criticism always welcome.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a query that updates rows in a table if a
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
I'm trying to write a regex function that will identify and replace a single
I'm trying to write a custom WPF ValidationRule to enforce that a certain property
I'm trying to write some PHP to upload a file to a folder on
I'm trying to write a stored procedure to select employees who have birthdays that
I'm trying to write a page that calls PHP that's stored in a MySQL
I am trying to write a SQL Server query but have had no luck
I'm trying to write an HttpModule to run on our SharePoint farm - essentially
I'm trying write a query to find records which don't have a matching record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.