ybdev
ybdev

Reputation: 25

BITS job throws an error trying to download a zip file

We get this error from the BITS job when trying to download a zip file from a remote server (we implemented an HTTP Handler for zip files on that server):

ERROR CODE: 0x80200013 - The server does not support the necessary HTTP protocol. Background Intelligent Transfer Service (BITS) requires that the server support the Range protocol header.
ERROR CONTEXT: 0x00000005 - The error occurred while the remote file was being processed.

My understanding is that the error suggests we should add the Content-Range header. I added the header, now the code looks like below:

context.Response.ContentType = "application/x-zip-compressed";
context.Response.AppendHeader("Content-Disposition", string.Format("inline; fileName={0}", downloadFileName));
context.Response.AppendHeader("Content-Range", "bytes " + start + "-" + end + "/" + size);
context.Response.AppendHeader("Content-Length", fs.Length.ToString());
fs.CopyTo(context.Response.OutputStream);

context.Response.Flush();
context.Response.Close();

, but I keep receiving the same error.

I also tried the following line:

context.Response.AppendHeader("Accept-Ranges", "bytes");

but ended up with a different error: "The connection with the server was terminated abnormally". The download link works perfectly fine in the browser.

i will appreciate any ideas, thanks!

Upvotes: 1

Views: 1590

Answers (1)

That error indicates that your server does not meet the HTTP Requirements for BITS Downloads. Does the server accept HEAD requests?

BITS users should configure download jobs with BITS_JOB_PROPERTY_DYNAMIC_CONTENT and BG_JOB_PRIORITY_FOREGROUND when targeting non-compliant servers. Bear in mind that this will result in BITS having to restart the download from scratch if/when it gets interrupted (e.g., due to connectivity issues or system reboot).

Upvotes: 2

Related Questions