现在这是我们遇到的问题,我们的程序正在请求XML文件,并且看到有可用的更新.然后它创建一个BITS作业下载它,然而BITS保持报告下载失败.我们可以使用相同的URL和IE / Firefox / Chrome下载文件.
所以我的问题:
TIdHTTPServer是否兼容BITS?
我问这个是因为我已经发现有这些下载要求的位工作.
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.
解决方法
这里是
IdHTTPHeaderInfo.pas aprox行770
- procedure TIdEntityRange.SetText(const AValue: String);
- var
- LValue,S: String;
- begin
- LValue := Trim(AValue);
- if LValue <> '' then
- begin
- S := Fetch(LValue,'-'); {do not localize}
- if S <> '' then begin
- FStartPos := StrToIntDef(S,-1);
- FEndPos := StrToIntDef(Fetch(LValue),-1);
- FSuffixLength := -1;
- end else begin
- FStartPos := -1;
- FEndPos := -1;
- FSuffixLength := StrToIntDef(Fetch(LValue),-1);
- end;
- end else begin
- FStartPos := -1;
- FEndPos := -1;
- FSuffixLength := -1;
- end;
- end;
这应该是
- procedure TIdEntityRange.SetText(const AValue: String);
- var
- LValue,'-'); {do not localize}
- if S <> '' then begin
- FStartPos := StrToInt64Def(S,-1);
- FEndPos := StrToInt64Def(Fetch(LValue),-1);
- FSuffixLength := -1;
- end else begin
- FStartPos := -1;
- FEndPos := -1;
- FSuffixLength := StrToInt64Def(Fetch(LValue),-1);
- end;
- end else begin
- FStartPos := -1;
- FEndPos := -1;
- FSuffixLength := -1;
- end;
- end;
一个Remy修复