#1 2023-07-13 06:46:19

gunix
Member
From: china
Registered: 2015-06-06
Posts: 5

There may be Error in ProcessStaticFile of Net.server.pas [solved]

if Context.ContentFromFile(fn, CompressGz) then
        OutContent := Context.Content                             ==>   fRespStatus := HTTP_SUCCESS              outContent  no need
      else
      begin
        FormatString('Impossible to find %', [fn], fErrorMessage);
        fRespStatus := HTTP_NOTFOUND;
      end;


follow :
  Context.Content := OutContent;                             ==>      if not ((OutContent <> '') and (OutContentType = STATICFILE_CONTENT_TYPE)) then     Context.Content := OutContent;               
  Context.ContentType := OutContentType;   


then can right download file

Last edited by gunix (2023-07-14 01:09:40)

Offline

#2 2023-07-13 07:09:15

gunix
Member
From: china
Registered: 2015-06-06
Posts: 5

Re: There may be Error in ProcessStaticFile of Net.server.pas [solved]

I See,  OnRequest call back shoud return HTTP_SUCCESS
OnRequest(Ctxt: THttpServerRequestAbstract): cardinal;   
begin
    Result:=HTTP_FOUND;         //default return value
   Ctxt.OutContentType:=TEXT_CONTENT_TYPE;   
   if StartWith(Ctxt.Url, uppercase('/upgradefile/')) then  begin
      Ctxt.OutContentType:=STATICFILE_CONTENT_TYPE; 
      ctxt.OutContent:=StringToUtf8('xxxxxxx');
      ctxt.RespStatus:= HTTP_SUCCESS;                                                      ==>   Result:=HTTP_SUCCESS;
   end

end;

Last edited by gunix (2023-07-14 01:17:15)

Offline

#3 2023-07-13 07:32:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: There may be Error in ProcessStaticFile of Net.server.pas [solved]

I am not sure I understand what you meant, sorry.

Do you mean that your callback should return result = 200 so that it works as expected?
So is it solved?

Offline

#4 2023-07-14 01:13:16

gunix
Member
From: china
Registered: 2015-06-06
Posts: 5

Re: There may be Error in ProcessStaticFile of Net.server.pas [solved]

ab wrote:

I am not sure I understand what you meant, sorry.

Do you mean that your callback should return result = 200 so that it works as expected?
So is it solved?

Yes

Offline

Board footer

Powered by FluxBB