home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
zkuste
/
delphi
/
nastroje
/
d3456
/
KBMWABD.ZIP
/
WABD_HTMLResponse.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2001-07-09
|
3KB
|
86 lines
unit WABD_HTMLResponse;
interface
uses SysUtils,WABD_Request,WABD_Response,WABD_Cookies,WABD_Utils,ISAPI2;
type
TWABD_CustomHTMLResponse = class(TWABD_CustomResponse)
protected
function FormatResponse:string; override;
end;
implementation
function TWABD_CustomHTMLResponse.FormatResponse:string;
var
i:integer;
fn:string;
cookiestr:string;
cookie:TWABD_Cookie;
s:string;
const
CR = #13#10;
begin
// Check if to redirect to another location.
if (Status=WABD_STATUS_OK) and (Location<>'') then Status:=WABD_STATUS_REDIRECT;
if (Status=WABD_STATUS_REDIRECT) and (Location='') then Status:=WABD_STATUS_OK;
// Build cookie list.
cookiestr:='';
if Assigned(Cookies) then
for i:=0 to Cookies.count-1 do
begin
cookie:=TWABD_Cookie(Cookies.Items[i]);
if Length(Trim(cookie.Name))>0 then
cookiestr:=cookiestr+'Set-Cookie: '+cookie.HeaderValue+';'+CR;
end;
// Format HTTP.
case Status of
WABD_STATUS_OK:
begin
if ContentDesc<>'' then
fn:='Content-Disposition: attachment;filename='+ContentDesc+CR
else
fn:='';
s:=Response.Text;
Result:='HTTP/1.0 200 OK'+CR+
cookiestr+
fn+
'Content-Type: '+ContentType+CR+
'Content-Length: '+inttostr(length(s))+CR+
Header.Text+
'Content:'+CR+CR+s;
end;
WABD_STATUS_AUTH:
begin
Result:='HTTP/1.0 401 Unauthorized'+CR+
'WWW-authenticate: Basic realm="'+ContentDesc+'"'+CR+
cookiestr+
'Content-type: text/plain'+CR+
'Content-Length: 14'+CR+
Header.Text+
'Content:'+CR+CR+'Access denied.';
end;
WABD_STATUS_REDIRECT:
begin
if ContentDesc<>'' then
fn:='Content-Disposition: attachment;filename="'+ContentDesc+'"'+CR
else
fn:='';
Result:='HTTP/1.0 302 Moved temporarily'+CR+
cookiestr+
'Location: '+Location+CR+
// 'Content-Type: '+ContentType+CR+
// 'Content-Length: '+inttostr(length(Data))+CR+
// fn+
// 'Content:'+CR+CR+Data;
Header.Text+
CR+CR;
end;
end;
end;
end.