/backup/xserver.pas

https://code.google.com/ · Pascal · 1218 lines · 593 code · 90 blank · 535 comment · 39 complexity · 59de355ec0f234001840c1da3815e36e MD5 · raw file

  1. unit xserver;
  2. {$MODE Delphi}
  3. { $MODE Delphi}
  4. {$H+}
  5. { $Y+}
  6. {$R+}
  7. {$M+}
  8. {$UNDEF STRING_IS_ANSI}
  9. {$DEFINE STRING_IS_UNICODE}
  10. interface
  11. uses
  12. {Windows,}{$IFNDEF LCL} Messages, {$ELSE} LCLIntf, LMessages, LclType,interfaces,LResources, {$ENDIF}
  13. SysUtils, Classes, Graphics, Controls, Forms,IdGlobal,
  14. Dialogs, IdBaseComponent, IdComponent, IdCustomTCPServer, IdCustomHTTPServer,
  15. IdHTTPServer,IdContext,IdCookie, IdException ,IdHeaderList,
  16. //idssl,
  17. //IdServerIOHandlerSocket,
  18. //IdServerIOHandlerSSLOpenSSL,
  19. // sharemem,
  20. //indyapp,
  21. IdIOHandlerStack,IdIOHandler,
  22. syncobjs,
  23. xsecgi,
  24. xsexml,
  25. xsefun,
  26. xseexp,
  27. xsecomp,
  28. xsedif, ExtCtrls ,
  29. xseftp,xsetimers,xsesmtp,xsesta,
  30. xsexse, StdCtrls, IdSSLOpenSSL ,IdSchedulerOfThread ;
  31. type
  32. { Txseusform }
  33. Txseusform = class(TForm)
  34. LOG: TMemo;
  35. procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
  36. procedure FormCreate(Sender: TObject);
  37. procedure FormDeactivate(Sender: TObject);
  38. // procedure notif(sender:tobject);
  39. private
  40. procedure GetPassword(var Password: String);
  41. procedure Status(ASender: TObject; const AStatus: TIdStatus;
  42. const AStatusText: string);
  43. public
  44. function verpeer(Certificate: TIdX509; AOk: Boolean): Boolean;
  45. end;
  46. txseusserver=class(tobject)
  47. server:tidhttpserver;
  48. sessionlist:tlist;
  49. // ssl:tIdSSLIOHandlerSocketbase;
  50. // connections:integer;
  51. procedure onCommandGet(AContext: TIdContext;
  52. ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  53. procedure OnInvalidSession(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var VContinueProcessing: Boolean; const AInvalidSessionID: String);
  54. constructor create;
  55. //private
  56. procedure sessionstart(Sender: TIdHTTPSession);
  57. private
  58. procedure sessionend(Sender: TIdHTTPSession);
  59. procedure serverConnect(AContext: TIdContext);
  60. procedure serverdisconnect(AContext:TIdContext);
  61. // procedure CreatePostStream(c:tidcontext;h:tidheaderlist;s:tstream);
  62. end;
  63. tsslserver=class(tobject)
  64. private
  65. server:tidhttpserver;
  66. // ssl:tIdSSLIOHandlerSocketbase;
  67. connections:integer;
  68. sessionlist:tlist;
  69. procedure onConnect(AContext: TIdContext);
  70. procedure onCommandGet(AContext: TIdContext;
  71. ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  72. constructor create;
  73. procedure sessionstart(Sender: TIdHTTPSession);
  74. // private
  75. procedure sessionend(Sender: TIdHTTPSession);
  76. end;
  77. // tlocked=class(tobject)
  78. // files:tstringlist;
  79. // function lockfile(st:string):boolean;
  80. // function unlockfile(st:string):boolean;
  81. // constructor create;
  82. // end;
  83. const
  84. crlf=^M^J;
  85. //tmpoutdir='c:\www\tmp\';
  86. //tmpindir='c:\website\cgi-temp\';
  87. isost=32000;
  88. whitespace=crlf+' ';
  89. inlins=',tt,span,strong,code,br,BR,img,em,b,i,a,strike,font,q,del,ins,value,FONT,STRONG,CODE,A,';g_myurl='http://valtweb.pc.helsinki.fi/cgi-shl/cgitalk.exe';
  90. var xseusserver: TxseusServer;ftpserver:txseusftp;
  91. sslserver:tsslserver;servicemode:boolean;
  92. xseusform: Txseusform;
  93. connections:integer;
  94. //uploadlimits:tstringlist;
  95. //timer:ttimertask; //locriti,
  96. logicriti:TCriticalSection;
  97. log:textfile;
  98. //g_locs:TLOCS;
  99. //cookie:string;
  100. {$IFNDEF LAZARUS} logstream:tfilestream;
  101. {$ENDIF}
  102. threadvar thrxs:txseus;mythreadelems:tlist;
  103. procedure logwrite(st:ANSIstring);
  104. implementation
  105. {$IFNDEF LCL}
  106. {$R *.dfm}
  107. uses xsesvc;
  108. {$ELSE}
  109. {x$R *.lfm}
  110. {$ENDIF}
  111. threadvar ResponseStream : TMemoryStream;
  112. respa:tidhttpresponseinfo;xso:txseus;actx:tidcontext;
  113. constructor tsslserver.create;
  114. var port:integer;
  115. ssl:TIdServerIOHandlerSSLOpenSSL;
  116. begin
  117. // port:=strtointdef(x_config.subs('commands/port'),80);
  118. try
  119. sessionlist:=tlist.Create;
  120. connections:=0;
  121. server:=tidhttpserver.create;
  122. server.SessionState:=true;
  123. server.onsessionstart:=sessionstart;
  124. // server.onsessionend:=sessionend;
  125. server.SessionTimeout:=1000000;
  126. server.DefaultPort:=443;
  127. server.oncommandget:=oncommandget;
  128. server.OnConnect:=onconnect;
  129. //server.active:=true;
  130. server.AutoStartSession:=true;
  131. //server.AutoStartSession:=false;
  132. ssl:=TIdServerIOHandlerSSLOpenSSL.create;
  133. //SSL.SSLOptions.Method := sslvSSLv2;//sslvSSLv3;sslvSSLv23;
  134. SSL.SSLOptions.Method := sslvSSLv3;
  135. //SSL.SSLOptions.Method :=sslvtlSv1;
  136. //ssl.ssloptions.certfile:='c:\xx\xseus.cer';
  137. //ssl.ssloptions.keyfile:='c:\xx\xseus.key';
  138. ssl.ssloptions.certfile:=extractfiledir(paramstr(0))+'\xseus.cer';
  139. ssl.ssloptions.keyfile:=extractfiledir(paramstr(0))+'\xseus.key';
  140. //& xseusform.memo1.lines.add('cert in '+ssl.ssloptions.certfile);
  141. logwrite('cert '+ssl.ssloptions.certfile);
  142. //ssl.onverifyPeer:=xseusform.verpeer;
  143. //ssl.ssloptions.verifymode:=[sslvrfPeer];
  144. //ssl.ongetpassword:=xseusform.getpassword;
  145. ssl.ssloptions.verifymode:=[];
  146. ssl.ssloptions.verifydirs:='';
  147. ssl.ssloptions.Mode :=sslmServer;
  148. // ssl.ssloptions.Mode := sslmUnassigned;
  149. ssl.ssloptions.VerifyDepth := 2;
  150. //ssl.OnStatus := xseusform.Status;
  151. //server.OnStatus := xseusform.Status;
  152. server.iohandler:=ssl;
  153. server.Active:=true;
  154. //ssl.OnVerifyPeer:=Txseusform.VERPEER;
  155. //TIdServerIOHandlerSSLOpenSSL
  156. //TIdServerIOHandlerSocket.create;
  157. //server.intercept:=TIdserverSSLIOHandler.create;
  158. //TIdSSLIOHandlerSocketOpenSSL
  159. //ClientServerIndySSLIOHandlerSocket
  160. //& xseusform.Memo1.lines.add('sslserver started on port 801');
  161. logwrite('Started SSL-server on port '+inttostr(server.defaultport));
  162. except
  163. logwrite('Failed to start SSL-server on port 443');
  164. end;
  165. end;
  166. constructor txseusserver.create;
  167. var port:integer;
  168. begin
  169. try
  170. sessionlist:=tlist.Create;
  171. port:=strtointdef(x_config.subs('commands/port'),80);
  172. connections:=0;
  173. g_smtpindir:=x_config.subs('//smtp/@indir');
  174. logwrite('SMTP INDIR:'+g_smtpindir);
  175. try
  176. //logwrite('trying to create a Xseus-server');
  177. server:=tidhttpserver.create;
  178. //server.sessionlist.
  179. server.maxconnections:=10;
  180. except logwrite('Failed to create a Xseus-server'); end;
  181. server.SessionState:=true;//false;
  182. server.onsessionstart:=sessionstart;
  183. write(log,'1-');
  184. server.onsessionend:=sessionend;
  185. // server.SessionTimeout:=25000;
  186. server.SessionTimeout:=strtointdef(x_config.subs('commands/sessiontime'),25000);
  187. //server.sessionlist.SessionTimeout:=15000;
  188. write(log,'2-');
  189. server.oninvalidsession :=oninvalidsession;
  190. server.DefaultPort:=port;
  191. server.oncommandget:=oncommandget;
  192. // server.OnContextCreated
  193. write(log,'3-(port:',port,')');
  194. server.active:=true;
  195. write(log,'4-');
  196. server.AutoStartSession:=true;
  197. //server.AutoStartSession:=false;
  198. //server.keepalive:=false;
  199. server.keepalive:=true;
  200. write(log,'5-');
  201. //xseusform.Memo1.text:='xseusserver started on port '+inttostr(port);
  202. logwrite('Started Xseus server app on port '+inttostr(port)+ '( sess_'+inttostr(server.sessiontimeout));
  203. except
  204. logwrite('Failed to start Xseus server app');
  205. end;
  206. end;
  207. {procedure txseusserver.CreatePostStream(c:tidcontext;h:tidheaderlist;s:tstream);
  208. begin
  209. // c.Connection.IOHandler.headerhasbeenwritten:=false;
  210. end;}
  211. procedure tsslserver.onConnect(AContext: TIdContext);
  212. begin
  213. //logwrite('ssl.connect:');
  214. inherited;
  215. //logwrite('ssl.connect2:');
  216. end;
  217. procedure logwrite(st:ANSIstring);
  218. begin
  219. // logicriti.Enter;
  220. try
  221. try
  222. if servicemode then
  223. // writeln(log,st)
  224. {$IFNDEF LCL}
  225. logstream.write(st[1],length(st))
  226. {$ENDIF}
  227. else
  228. {begin
  229. try
  230. FEventLogger.LogMessage(st, EVENTLOG_ERROR_TYPE, 0, 0); //writeln(log,st);
  231. EXCEPT WRITELN(log,'failed to log');end;
  232. end else}
  233. begin
  234. //if xseusform.LOG.Lines.count>1000 then xseusform.LOG.Lines.Clear;
  235. xseusform.LOG.Lines.add(st);
  236. {$IFNDEF LCL}
  237. logstream.write(st[1],length(st))
  238. {$ENDIF}
  239. end;
  240. except end;
  241. finally
  242. // logicriti.Leave;
  243. end;
  244. end;
  245. function txseusform.verpeer(Certificate: TIdX509; AOk: Boolean): Boolean;
  246. begin
  247. //writeln('cerify');
  248. result:=true;
  249. end;
  250. function HexToString(H: String): String;
  251. var I : Integer;
  252. begin
  253. Result:= '';
  254. for I := 1 to length (H) div 2 do
  255. Result:= Result+Char(StrToInt('$'+Copy(H,(I-1)*2+1,2)));
  256. end;
  257. function HtmlOutput(var F: TTextRec): Integer;
  258. var tx,TX2:ANSIstring;TBP:pchar;
  259. tb:tidbytes;
  260. begin
  261. try
  262. if f.bufpos=0 then exit;
  263. if f.bufptr=nil then exit;
  264. {if not xso.httpinited then
  265. begin
  266. try
  267. respa.WriteHeader;xso.httpinited:=true;
  268. respa.HeaderHasBeenWritten:=true;
  269. finally
  270. end;
  271. end;}
  272. with F do
  273. begin
  274. try
  275. //actx.connection.iohandler.write(copy(bufptr,0,bufpos));
  276. // respa.contenttext:=inttohex(bufpos,1)+crlf+copy(bufptr,0,bufpos)+crlf;
  277. { respa.contenttext:=copy(bufptr,0,bufpos)+crlf;
  278. respa.WriteContent;
  279. respa.ContentText:='';
  280. sleep(3000);
  281. BufPos := 0;
  282. Result := 0;
  283. exit;
  284. // actx.connection.iohandler.DefStringEncoding:=nil;
  285. tx:=inttohex(bufpos-1,1)+crlf+copy(bufptr,0,bufpos)+crlf;
  286. TRY
  287. tbp:=@tx[1];
  288. // SetString(TX2, tbp,Length(TX));
  289. EXCEPT
  290. LOGWRITE('NOTX2');
  291. END;
  292. logwrite('TX::'+inttostr(length(tx))+'///'+TX+'\\\');
  293. //logwrite('TX2::'+inttostr(length(tx2))+'///'+TX2+'\\\');
  294. // actx.connection.iohandler.write(rawtobytes(tx[1],length(tx)-1),length(tx)-1);
  295. //sleep(5000);
  296. }
  297. TRY
  298. if bufpos=0 then exit;
  299. //-- tx:=inttohex(bufpos,4)+crlf+copy(bufptr,0,bufpos)+crlf;//+CRLF;
  300. except
  301. logwrite('noGO Tx///'+inttostr(length(tx)));//+respa.contenttext+' //'+inttostr(length(respa.contenttext)));
  302. end;
  303. try
  304. tbp:=@tx[1];
  305. //rawtobytes(tx[1],length(tx));
  306. //tb:=rawtobytes(tx[1],length(tx));
  307. // actx.connection.iohandler.write(TIDBYTES(tbp),length(tx),0);
  308. except
  309. logwrite('noGO RTB///'+inttostr(length(tx)));//+respa.contenttext+' //'+inttostr(length(respa.contenttext)));
  310. end;
  311. try
  312. //actx.connection.iohandler.WriteDirect(RAWTObytes(tbp,LENGTH(TX)), Length(tx), 0);
  313. // actx.connection.iohandler.Writedirect(tb, Length(tx), 0);
  314. actx.Connection.IOHandler.Write(RawToBytes(PAnsiChar(tx)^, Length(tx)));
  315. //actx.connection.iohandler.Write(@tb, Length(tx), 0);
  316. //actx.connection.iohandler.Writedirect(tidbytes(@tx[1]), Length(tx), 0);
  317. except
  318. logwrite('noGO WD///'+inttostr(length(tx))+'/'+inttostr(sizeof(tb)));//+respa.contenttext+' //'+inttostr(length(respa.contenttext)));
  319. end;
  320. BufPos := 0;
  321. Result := 0;
  322. except
  323. logwrite('nooutputt///'+tx);//+respa.contenttext+' //'+inttostr(length(respa.contenttext)));
  324. end;
  325. end;
  326. exit;
  327. {
  328. with F do
  329. begin
  330. if respa<>nil then
  331. begin
  332. if not xso.httpinited then
  333. begin
  334. try
  335. respa.WriteHeader;xso.httpinited:=true;
  336. respa.HeaderHasBeenWritten:=true;
  337. //respa.contenttext:=copy(bufptr,0,bufpos)+'/INITED';
  338. //respa.WriteContent;
  339. except
  340. logwrite('failed httpinit');
  341. raise;
  342. end;
  343. end;
  344. try
  345. //respa.contentstream.write(BufPtr^, BufPos);
  346. //respa.ContentText:='';
  347. TRY
  348. if bufpos>bufsize then logwrite('ffffffffffffff'+inttostr(bufsize));
  349. respa.ContentText:=copy(pchar(bufptr),0,bufpos);
  350. except
  351. logwrite('failed htmloutput'+respa.contenttext);
  352. //LAZARUS FREEZES: raise;
  353. end;
  354. TRY
  355. //logwrite('TRY htmloutput'+respa.contenttext+inttostr(bufpos));
  356. respa.WriteContent;
  357. except
  358. logwrite('failed WRITECONTENT'+respa.contenttext);
  359. //LAZARUS FREEZES: raise;
  360. end;
  361. except
  362. logwrite('failed htmloutput'+respa.contenttext);
  363. //LAZARUS FREEZES: raise;
  364. end;
  365. BufPos := 0;
  366. Result := 0;
  367. end;
  368. end;
  369. }
  370. except
  371. logwrite('***********************didnot output');
  372. end;
  373. end;
  374. function HtmlCLOSE(var F: TTextRec): Integer;
  375. begin
  376. FileClose(F.Handle); { *Converted from CloseHandle* }
  377. result:=0;
  378. END;
  379. function HtmlOpen(var F: TTextRec): Integer;
  380. begin
  381. with F do begin
  382. begin
  383. Mode := fmOutput;
  384. InOutFunc := @HtmlOutput;
  385. FlushFunc := @HtmlOutput;
  386. CloseFunc := @HtmlClose;
  387. end;
  388. Result := 0;
  389. end;
  390. end;
  391. procedure AssignHtml(var F: TextFile);
  392. begin
  393. with TTextRec(F) do
  394. begin
  395. FillChar(F, SizeOf(F), 0);
  396. Mode := fmClosed;
  397. BufSize := SizeOf(Buffer);
  398. BufPtr := @Buffer;
  399. OpenFunc := @HtmlOpen;
  400. htmlopen(ttextrec(f));
  401. end;
  402. end;
  403. {procedure TForm1.Button1Click(Sender: TObject);
  404. begin
  405. xseusserver.server.active:=false;
  406. xseusserver.server.bindings.clear;
  407. xseusserver.server.Free;
  408. xseusserver.Free;
  409. xseusserver:=txseusserver.create;
  410. xseusserver.connections:=0;
  411. end;
  412. }
  413. procedure Txseusform.FormCreate(Sender: TObject);
  414. var inif:string;//f:textfile;
  415. //timerini:tstringlist;
  416. i:integer;timersini:ttag;
  417. begin
  418. try
  419. try
  420. logwrite('formcreate ');
  421. // ReportMemoryLeaksOnShutdown := DebugHook <> 0;
  422. try
  423. g_locs:=tlocs.create;
  424. //criti:=tcriticalsection.create;
  425. logicriti:=tcriticalsection.create;
  426. //timer.interval:=17000;
  427. //timer.OnTimer:=notif;
  428. inif:=extractfiledir(paramstr(0))+'\xseus.xsi';
  429. //if not FileExistsUTF8(inif) { *Converted from FileExists* } then
  430. if not FileExists(inif) { *Converted from FileExists* } then
  431. inif:=extractfiledir(paramstr(0))+'\xseus.ini';
  432. //inif:='C:\XSER\xseus.ini';
  433. logwrite('read config '+inif);
  434. x_config:=ttag.create;
  435. x_config.fromfile(inif,nil);
  436. except logwrite('failed to read inifile from '+inif); exit; end;
  437. xseusserver:=TxseusServer.create;
  438. //exit;
  439. // xseusserver.server.OndisConnect:=xseusserver.serverconnect;
  440. xseusserver.server.OndisConnect:=xseusserver.serverdisconnect;
  441. sslserver:=TsslServer.create;
  442. logwrite('sslservr created***********');
  443. //x_config.fromfile('c:\xi\xseus.ini',nil);
  444. except logwrite('failed to load servers'); exit; end;
  445. try
  446. xsecache:=TSTRINGLIST.CREATE;
  447. x_commands:=x_config.subt('commands');
  448. TRY
  449. //LOGWRITE(X_COMMANDS.XMLIS);
  450. EXCEPT
  451. logwrite('fauiled lsit x_coms');
  452. end;
  453. x_dirs:=x_commands.subt('dirs');
  454. logwrite('config read '+x_config.vari+ ' from ' +inif);
  455. try
  456. TIMERSINI:=x_commands.subt('timers');
  457. if timersini<>nil then
  458. for i:=0 to timersini.subtags.Count - 1 do
  459. begin
  460. //logwrite(ttag(timersini.subtags[i]).listraw);
  461. if ttag(timersini.subtags[i]).vari='timer' then
  462. ttimertask.Create(ttag(timersini.subtags[i]).attributes);//(self);
  463. end;
  464. except logwrite('problems: timers /xseus.ini, timers-section'); end;
  465. // logwrite('timer='+ini.text);
  466. // logwrite(x_commands.listraw);
  467. try
  468. x_ftp:=x_commands.subt('ftp');
  469. x_smtp:=x_commands.subt('smtp');
  470. except logwrite('problems: xweus.ini, ftp/smtp-section'); end;
  471. try
  472. if x_ftp<>nil then
  473. begin
  474. logwrite('ftpserver create:');
  475. ftpserver:=txseusftp.create;
  476. logwrite('ftpserver created');
  477. end;
  478. except logwrite('problems: ftp-server'); end;
  479. try
  480. if x_smtp<>nil then
  481. begin
  482. smtpserver:=txseussmtp.create(x_smtp);
  483. logwrite('smtpserver created');
  484. end;
  485. except logwrite('problems: smtp-server. '); end;
  486. except logwrite('failed to initialize'); exit; end;
  487. except logwrite('initialization failed '+inif); exit; end;
  488. logwrite('FORM CREATED');
  489. end;
  490. procedure Txseusform.FormCloseQuery(Sender: TObject; var CanClose: boolean);
  491. begin
  492. //showmessage('DEACIVATE');
  493. xseusserver.server.active:=false;
  494. //showmessage('DEACIVATEd');
  495. xseusserver.free;
  496. end;
  497. procedure Txseusform.FormDeactivate(Sender: TObject);
  498. begin
  499. end;
  500. //function txseusserver.sessionstart:TOnSessionStartEvent;
  501. procedure startsession(Sender: TIdHTTPSession);
  502. var ase:ttag;
  503. begin
  504. //if ase=nil then
  505. ase:=ttag.create;
  506. ase.vari:='session';
  507. ase.attributes.add('class=system:login');
  508. //ase.attributes.add('dir='+sesdir);
  509. //if xseus.x_newcookie<>'' then
  510. ase.attributes.add('id='+sender.sessionid);
  511. //else
  512. // ase.attributes.add('id='+cookies.values['xseus_session']);
  513. ase.attributes.add('time='+timetostr(now));
  514. //ase.attributes.add('ip='+xseus.x_cgi.subs('REMOTE_ADDR'));
  515. ase.attributes.add('ip='+sender.RemoteHost);
  516. ase.attributes.add('new=true');
  517. sender.content.addobject('welcome',ase);
  518. sender.content.addobject('connections',tstringlist.create);
  519. LOGWRITE(sender.RemoteHost+'|'
  520. +sender.sessionid+'Session startED, '+ sender.content.text);
  521. //& xseusform.Memo1.lines.add('Session started, '+ sender.content.text);
  522. end;
  523. procedure TXSEUSSERVER.sessionstart(Sender: TIdHTTPSession);
  524. var i:integer;ases: TIdHTTPSession;
  525. begin
  526. //if sender.SessionID='sauna_timer' then exit;
  527. //inherited;
  528. //if sender.
  529. logwrite('XSEUSsession start'+sender.SessionID);
  530. startsession(sender);
  531. try
  532. try
  533. sessionlist.add(sender);
  534. except
  535. logwrite('sesslist probs');
  536. end;
  537. for i:=0 to SessionList.Count-1 do
  538. begin
  539. ases:=tidhttpsession(SessionList[i]);
  540. IF ASES.Content<>nil then
  541. logwrite(inttostr(i)+'sess:'+ases.SessionID+':'+ ases.RemoteHost+'|');
  542. //sender.content.add('welcome');
  543. end;
  544. except
  545. logwrite('sesslist items probs');
  546. end;
  547. end;
  548. procedure TsslSERVER.sessionstart(Sender: TIdHTTPSession);
  549. var i:integer;ases: TIdHTTPSession;
  550. begin
  551. //if sender.SessionID='sauna_timer' then exit;
  552. //inherited;
  553. //if sender.
  554. logwrite('XSEUSsession start'+sender.SessionID);
  555. startsession(sender);
  556. try
  557. try
  558. sessionlist.add(sender);
  559. except
  560. logwrite('sesslist probs');
  561. end;
  562. for i:=0 to SessionList.Count-1 do
  563. begin
  564. ases:=tidhttpsession(SessionList[i]);
  565. IF ASES.Content<>nil then
  566. logwrite(inttostr(i)+'sess:'+ases.SessionID+':'+ ases.RemoteHost+'|');
  567. //sender.content.add('welcome');
  568. end;
  569. except
  570. logwrite('sesslist items probs');
  571. end;
  572. end;
  573. procedure TsslSERVER.sessionend(Sender: TIdHTTPSession);
  574. begin
  575. //&xseusform.Memo1.lines.add('SSLsession ended'+sender.SessionID);
  576. //ttag(sender.content.Objects[0]).subtags.free;
  577. //ttag(sender.content.Objects[0]).attributes.free;
  578. // listwrite(ttag(sender.content.Objects[0]));
  579. logwrite('end sslsession');
  580. if sender.Content.count>0 then
  581. begin
  582. ttag(sender.content.Objects[0]).clear;
  583. ttag(sender.content.Objects[0]).free;
  584. end;
  585. end;
  586. procedure TXSEUSSERVER.sessionend(Sender: TIdHTTPSession);
  587. begin
  588. //& xseusform.Memo1.lines.add('session ended'+sender.SessionID);
  589. //ttag(sender.content.Objects[0]).subtags.free;
  590. //ttag(sender.content.Objects[0]).attributes.free;
  591. // listwrite(ttag(sender.content.Objects[0]));
  592. logwrite('end session'+inttostr(sender.content.count));
  593. if sender.Content.count>0 then
  594. begin
  595. if sessionlist.IndexOf(sender)>=0 then
  596. sessionlist.delete(sessionlist.IndexOf(sender)) else
  597. logwrite('remains in sessionlist');
  598. //ttag(sender.content.Objects[0]).clear;
  599. ttag(sender.content.Objects[0]).free;
  600. end;
  601. inherited;
  602. { if ttag(sender.content.Objects[0])<>nil then
  603. begin
  604. //ttag(sender.content.Objects[0]).clear;
  605. ttag(sender.content.Objects[0]).free;
  606. end;}
  607. end;
  608. procedure LISTLOCS;begin end;
  609. {var
  610. AList: TList;
  611. RecThread: tidcontext;
  612. i: Integer;
  613. cret,extt,kert,usrt:filetime;
  614. FUNCTION _secSince(filtim:filetime):integer;
  615. var systemtime:TSystemTime;
  616. LocalTime : TFileTime;
  617. begin
  618. if FileTimeToLocalFileTime(FilTim, LocalTime) then
  619. if FileTimeToSystemTime(localtime, systemTime) then
  620. Result := round(24*3600*(now-(SystemTimeToDateTime(SystemTime))));
  621. end;
  622. FUNCTION _SHTIME(filtim:filetime):tdatetime;
  623. var systemtime:TSystemTime;
  624. LocalTime : TFileTime;
  625. begin
  626. //if FileTimeToLocalFileTime(FilTim, LocalTime) then
  627. if FileTimeToSystemTime(filtim, systemTime) then
  628. Result := (SystemTimeToDateTime(SystemTime));
  629. end;
  630. begin
  631. //AList := TList.Create;
  632. AList := Xseusserver.server.contexts.LockList;
  633. try
  634. for i := 0 to AList.count - 1 do
  635. begin
  636. try
  637. RecThread := tidcontext(AList.Items[i]);
  638. GetThreadTimes(TIdYarnOfThread(recthread.yarn).thread.handle, cret,extt,kert,usrt);
  639. logwrite('#'+inttostr(i)+' '+inttostr(_secsince(cret))+' '
  640. +inttostr(usrt.dwLowDateTime div 1000000)+' '
  641. +inttostr(kert.dwLowDateTime div 1000000));
  642. //RecThread.yarn.
  643. //RecThread.Connection.Disconnect;
  644. //RecThread.Terminate;
  645. //AList.Remove(RecThread);
  646. except logwrite('failed to list locks');end;
  647. end;
  648. finally
  649. Xseusserver.server.contexts.UnLockList;
  650. end;
  651. //if alist<>nil then AList.Free;
  652. end;}
  653. procedure txseusserver.serverConnect(AContext: TIdContext);
  654. begin
  655. EXIT;//FOR LAZARUS
  656. //logwrite('connect');
  657. logicriti.Enter;
  658. try
  659. //listlocs;
  660. finally
  661. logicriti.leave;
  662. end;
  663. end;
  664. procedure txseusserver.serverdisConnect(AContext: TIdContext);
  665. begin
  666. logwrite('disconnect');
  667. end;
  668. procedure doconnection(AContext: TIdContext;
  669. ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  670. var xs:txseus;st,infile:string; // resst:tstringlist;
  671. //ReadCookie : TIdCookie;//RFC2109;
  672. //WriteCookie : TIdserverCookie;i:integer;
  673. threadelems:tlist;threadstates:tlist;stime:double;ohep:integer;
  674. locked:boolean;aTASK:tidcontext;
  675. RecThread: TIdcontext;//i:integer;
  676. ses:tidhttpsession;
  677. begin
  678. try
  679. try
  680. //try
  681. // for i := 0 to xseusserver.sessionlist.Count - 1 do
  682. // logwrite('**asess');//+datetimetostr(tidhttpsession(sessionlist.items[i]).lasttimestamp));
  683. //except writeln('mo list');end;
  684. while connections>10 do
  685. sleep(1000);
  686. //listlocs;
  687. //if xseusserver.server.contexts<>nil then
  688. stime:=((now));
  689. {for i := 0 to -10 do //aRequestInfo.Cookies.items.Count - 1 do
  690. begin
  691. try
  692. ReadCookie := aRequestInfo.Cookies.items[i];
  693. except break;end;
  694. //logwrite('cookie'+inttostr(i)+readcookie.cookiename+'='+readcookie.cookietext);
  695. end;}
  696. // xseusserver.server.CreateSession(AContext,aResponseInfo,aRequestInfo);
  697. {
  698. { ReadCookie := aRequestInfo.Cookies.Cookie['IDHTTPSESSIONID'];
  699. try
  700. logwrite('COOKIE:'+readcookie.cookiename+'|=|'+readcookie.value );
  701. logwrite('COOKIE:'+readcookie.cookiename+'|=|'+readcookie.cookietext );
  702. except
  703. logwrite('NOCOOKIE');
  704. end;
  705. try
  706. xseusserver.server.CreateSession(AContext,aResponseInfo,aRequestInfo);
  707. if xseusserver.server.sessionlist.getsession(readcookie.value,'127.0.0.1')<>nil then
  708. logwrite('got session') else
  709. begin
  710. logwrite('nossession');
  711. //sessio:=
  712. ses:=tidhttpsession.CreateInitialized(xseusserver.server.sessionlist,readcookie.cookiename+'='+readcookie.value,arequestinfo.remoteip);
  713. startsession(ses);
  714. // arequestinfo.session:=ses;
  715. end;
  716. except
  717. logwrite('failssession');
  718. end;
  719. }
  720. st:=arequestinfo.document;
  721. logwrite('xxxxxxxxxxxxxxxxxxxxx'+st);
  722. logwrite('start: '+arequestinfo.document+' id=' //+arequestinfo.session.sessionid
  723. //+ ':' + arequestinfo.session.content.text
  724. + ' active='+inttostr(connections) +' mem:'+inttostr(getheapstatus.totalallocated));
  725. //logwrite('start request:'+st+'****');
  726. st:=ansilowercase(copy(st,_poslast('.',st),999));
  727. //logwrite('start request:'+st+'****');
  728. if st='.ico' then exit;
  729. if (st<>'.htme') and (st<>'.htmi') then
  730. //requests for files not ending .htme are sent as is
  731. begin
  732. try
  733. //
  734. infile:=ansilowercase(arequestinfo.document);
  735. infile:=_mapurltofile(infile, x_commands.subt('mappings'));
  736. if extractfilename(infile)='' then
  737. begin
  738. infile:=infile+'index.htm';
  739. //--if not FileExistsUTF8(infile) { *Converted from FileExists* } then
  740. if not FileExists(infile) { *Converted from FileExists* } then
  741. infile:=infile+'l'
  742. end
  743. else
  744. if extractfileext(infile)='' then
  745. begin
  746. aresponseinfo.redirect(arequestinfo.document+'/');
  747. exit;
  748. end;
  749. //--if not FileExistsUTF8(infile) { *Converted from FileExists* } then
  750. if not FileExists(infile) { *Converted from FileExists* } then
  751. begin
  752. if not aResponseInfo.HeaderHasBeenWritten then
  753. begin
  754. // set error code
  755. aResponseInfo.ResponseNo := 404;
  756. aResponseInfo.ResponseText := 'Document not found';
  757. // write header
  758. aResponseInfo.WriteHeader;
  759. end else
  760. // return content
  761. aResponseInfo.ContentText := 'The document requested is not available.';
  762. aResponseInfo.WriteContent;
  763. exit;
  764. end;
  765. try
  766. if st='ico' then
  767. aresponseinfo.contenttype:='';
  768. if st='.htm' then
  769. aresponseinfo.contenttype:='text/html';
  770. if st='.html' then
  771. aresponseinfo.contenttype:='text/html';
  772. if st='.txt' then
  773. aresponseinfo.contenttype:='text/plain';
  774. if st='.ics' then
  775. begin
  776. aresponseinfo.contenttype:='text/calendar';
  777. aResponseinfo.CharSet := 'utf-8';
  778. end;
  779. if st='.svg' then
  780. begin
  781. logwrite('svg');
  782. aresponseinfo.contenttype:='image/svg+xml';
  783. aresponseinfo.contentdisposition:='inline';
  784. end;
  785. if st='.rtf' then
  786. aresponseinfo.contenttype:='application/rtf';
  787. if st='.pdf' then
  788. aresponseinfo.contenttype:='application/pdf' else
  789. if aresponseinfo.contenttype<>'' then
  790. begin
  791. //aresponseinfo.contentstream:=tfilestream.create(infile,fmopenread)
  792. end;
  793. aresponseinfo.contentdisposition:='inline';
  794. if st='.css' then
  795. begin
  796. aresponseinfo.contenttype:='text/css';
  797. logwrite('serveCSS');
  798. end;
  799. logwrite(' servefile'+infile);
  800. //aresponseinfo.ServeFile(Acontext, infile);
  801. aresponseinfo.smartServeFile(Acontext, arequestinfo,infile);
  802. except logwrite('could not servefile'+infile);
  803. end;
  804. finally
  805. //resst.Clear;resst.Free;
  806. end;
  807. exit;
  808. end;
  809. logwrite('start htme request');
  810. connections:=connections+1;
  811. respa:=aresponseinfo;
  812. actx:=acontext;
  813. // respa.contenttype:='text/raw';
  814. //respa.HeaderHasBeenWritten:=false;
  815. // respa.writeheader;
  816. logwrite('wrotehhedeaer');
  817. //respa.HeaderHasBeenWritten:=true;
  818. { respa.contenttext:='6'+crlf+'Xuihai';
  819. respa.WriteContent;
  820. respa.contenttext:=crlf+'0'+crlf+'';
  821. respa.WriteContent;
  822. logwrite('wrotehhedeaer');
  823. //respa.contenttext:='hiphei';
  824. //respa.WriteContent;
  825. //exit;
  826. }
  827. //respa.HeaderHasBeenWritten:=true;
  828. // assignhtml(output); //to be able to use "write/writeln" in subsequent programs
  829. //Respa.CharSet := 'utf-8';
  830. // respa.TransferEncoding:='chunked';
  831. Respa.Contenttype := 'text/html; charset=utf-8';
  832. respa.TransferEncoding:='chunked';
  833. respa.WriteHeader;
  834. respa.ContentEncoding:='utf-8';
  835. // actx.connection.iohandler.writeln('A'+CRLF+'0123456789');
  836. { aresponseinfo.HeaderHasBeenWritten:=false;
  837. respa.WriteHeader;
  838. with actx.connection.iohandler do
  839. begin
  840. WriteLn('HTTP/1.1 200 OK');
  841. WriteLn('Content-Type: text/html');
  842. //WriteLn('Content-length: 0');
  843. WriteLn('Transfer-encoding: chunked');
  844. WriteLn();
  845. //writeln('0');
  846. end;
  847. // Disconnect;
  848. //EXIT;
  849. //exit;}
  850. //actx.connection.iohandler.writeln('xxxxxxxxxxxxxxxxxx');
  851. //EXIT;
  852. try
  853. //if arequestinfo.session=nil then
  854. // xseusserver.server.createsession(acontext,aresponseinfo,arequestinfo);
  855. try
  856. assignhtml(output); //to be able to use "write/writeln" in subsequent programs
  857. except logwrite('failed assightnml');end;
  858. // respa.writeheader;
  859. { writeln('0987654321');
  860. writeln('1234567890');
  861. writeln('0987654321');
  862. writeln('1234567890');
  863. writeln('EKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  864. writeln('1234567890');
  865. writeln('TOKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  866. writeln('1234567890');
  867. writeln('2EKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  868. writeln('1234567890');
  869. writeln('2TOKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  870. writeln('1234567890');
  871. writeln('3EKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  872. writeln('1234567890');
  873. writeln('3TOKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖASDFOAKSDJFLAJSLDFKJASDLKFJALKSDJFASLSDKFJLAKSDJFALSDKFJ');
  874. writeln('1234567890');
  875. writeln('4EKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ');
  876. writeln('1234567890');
  877. writeln('4TOKAT ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖASDFOAKSDJFLAJSLDFKJASDLKFJALKSDJFASLSDKFJLAKSDJFALSDKFJ');
  878. writeln('1234567890');
  879. writeln('MELKOPITKAÖÄÖÄÖ-ÄÄÖÄÄÖÄÖADFÄÖKLASDÄFLÖ SADÄFLAÄSDÖFLÄ ASÖDLFÄ ÖASDLF ÄASÖDLF ÄÖALS FÄLASDÄFLÖ AÄS');
  880. writeln('1234567890');
  881. writeln('RIVINVAIHDOT;ÖÄÖÄÖ-ÄÄÖÄÄÖÄÖ'+CRLF+'ASFASDF'+CRLF+'ÖALSKDFÖASLDKF');
  882. writeln('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  883. writeln('PITKAÖÄÖÄÖ-ÄÄÖÄÄÖÄÖADFÄÖKLASDÄFLÖ SADÄFLAÄSDÖFLÄ ASÖDLFÄ ÖASDLF ÄASÖDLF ÄÖALS FÄLASDÄFLÖ AÄSÖÄÖÄÖ-ÄÄÖÄÄÖÄÖADFÄÖKLASDÄFLÖ SADÄFLAÄSDÖFLÄ ASÖDLFÄ ÖASDLF ÄASÖDLF ÄÖALS FÄLASDÄFLÖ AÄSÖÄÖÄÖ-ÄÄÖÄÄÖÄÖADFÄÖKLASDÄFLÖ SAD');
  884. writeln('BBBBBBBBBBBBBBBBBBBBBBBBBBBB');
  885. writeln('CCCCCCCCCCCCCCCCCCCCCCC');
  886. }
  887. //writeln;
  888. // respa.contenttext:='00'+crlf;
  889. //respa.WriteContent;
  890. //exit;
  891. xs:=txseus.create(true);
  892. TRY
  893. infile:=_mapurltofile(ansilowercase(arequestinfo.document), x_commands.subt('mappings'));
  894. except logwrite('failed TXSEUS.CREATE');end;
  895. // logwrite('**'+infile+'**'+x_commands.subt('mappings').listraw);
  896. xs.ifile:=infile;
  897. logwrite('createdit:'+xs.ifile);
  898. xs.locked:=g_locs.lockfile(xs.ifile);
  899. if not xs.locked then xs.locks.add(xs.ifile);
  900. //locked:=false;
  901. //if xs.locked then
  902. //begin
  903. // logwrite('LOCKED:'+g_locs.locks.text);
  904. // exit;
  905. //end;
  906. xso:=xs;
  907. xs.httpinited:=false;
  908. //xs.httpinited:=true;
  909. logwrite('session?');
  910. xs.x_session:=ttag(arequestinfo.session.content.objects[0]);
  911. logwrite('session!');
  912. xs.x_connections:=tstringlist(arequestinfo.session.content.objects[1]);
  913. logwrite('session2!');
  914. //respa.writeheader;
  915. xs.ns:='xse:';
  916. xs.request:=ARequestInfo;
  917. xs.response:=AResponseInfo;
  918. //acontext.Connection.
  919. //acontext.Connection.IOHandler.ReadTimeOut := 300000; //5 mins
  920. //acontext.Connection.IOHandler.ReadTimeOut := 300; //5 mins
  921. logwrite('tryit:'+xs.ifile);
  922. xs.doit;
  923. //write('didit:'+xs.ifile+xs.x_handler.vali+xs.x_handler.attributes.text);
  924. logwrite('didit:'+xs.ifile);
  925. finally
  926. try
  927. connections:=connections-1;
  928. try
  929. //try
  930. //if not locked then g_locs.freefile(infile);
  931. // except logwrite('failed freefile'+inttostr(g_locs.locks.count));
  932. // end;
  933. xs.clear;
  934. except logwrite('failed xseus.clear');end;
  935. try
  936. logwrite('did:'+xs.ifile);
  937. respa.contenttext:='0'+crlf+crlf;
  938. respa.WriteContent;
  939. //writeln('');
  940. xs.free;
  941. except logwrite('failed xseus.free');end;
  942. except logwrite('failed doconnection finally');end;
  943. end;
  944. except logwrite('failed doconnectionxx');end;
  945. finally
  946. ohep:=getheapstatus.totalallocated;
  947. logwrite('stop '+infile +' s.'
  948. +inttostr(round((now-stime)*24*36000))
  949. +' ses= '+ inttostr(connections)
  950. +' bytes: ' +inttostr(getheapstatus.totalallocated)
  951. );
  952. end;
  953. end;
  954. {procedure txseusform.notif(sender: tobject);
  955. var sched:ttimertask;
  956. begin
  957. xseusform.memo1.lines.add('x'+datetimetostr(now));
  958. //sched:=timertask.create(cookie);
  959. sched:=ttimertask.create(nil);
  960. sched.Free;
  961. //httppost('http://localhost/test.htme?sauna','',nil,true);
  962. end;}
  963. procedure txseusserver.OnInvalidSession(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var VContinueProcessing: Boolean; const AInvalidSessionID: String);
  964. begin
  965. logwrite('invalid session');
  966. end;
  967. procedure txseusserver.onCommandGet(AContext: TIdContext;
  968. ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  969. var xs:txseus;st,ifile:string; resst:tstringlist;
  970. //ReadCookie : TIdserverCookie;
  971. //WriteCookie : TIdserverCookie;i:integer;
  972. threadelems:tlist;threadstates:tlist;stime:double;ohep:integer;
  973. begin
  974. //aresponseinfo.HeaderHasBeenWritten:=false;
  975. logwrite('VERSION:'+server.Version);
  976. respa:=aresponseinfo;
  977. actx:=acontext;
  978. // server.CreateSession(AContext,aResponseInfo,aRequestInfo);
  979. // respa.HasContentLength:=false;
  980. { respa.Transferencoding:='chunked';
  981. respa.writeheader;
  982. aresponseinfo.HeaderHasBeenWritten:=false;
  983. with actx.connection.iohandler do
  984. begin
  985. WriteLn('HTTP/1.1 200 Continue');
  986. //WriteLn('HTTP/1.1 100 Continue');
  987. WriteLn('Content-Type: text/html; charset=UTF-8');
  988. // WriteLn('Content-Length: ');
  989. //WriteLn('Transfer-Encoding: chunked');
  990. WriteLn('Connection: Keep-Alive');
  991. WriteLn('Set-Cookie: hui=hai; Path=/');
  992. WriteLn();
  993. write('<h1>hello wordl</h1>');
  994. write('<h1>byby world</h1>');
  995. end;
  996. //actx.Connection.close;
  997. actx.Connection.Disconnect;
  998. exit;
  999. }
  1000. if arequestinfo.document='/favicon.ico' then exit
  1001. ;//else
  1002. //logwrite('GET:'+arequestinfo.document);
  1003. if arequestinfo.session=nil then
  1004. begin
  1005. server.createsession(acontext,aresponseinfo,arequestinfo);
  1006. //logwrite('new session');
  1007. end;
  1008. // if pos('xxxx',arequestinfo.document)>0 then
  1009. // begin
  1010. //logwrite('xxx');
  1011. // exit;
  1012. // end;
  1013. try
  1014. try
  1015. logwrite('dddddddddddddddddoooooooooooooo');
  1016. doconnection(AContext, ARequestInfo,AResponseInfo);
  1017. except
  1018. on E: EIdException do begin
  1019. logwrite('indy exception');
  1020. // Handle Indy exception here
  1021. end;
  1022. end;
  1023. finally
  1024. {$IFDEF LAZARUS}
  1025. logwrite('stopget');
  1026. EXIT;
  1027. //close(output);
  1028. //htmlclose(ttextrec(output));
  1029. {$ENDIF}
  1030. end;
  1031. //logwrite('stopget');
  1032. //xseusform.memo1.lines.add(arequestinfo.rawheaders.text);
  1033. //xseusform.memo1.lines.add('******'+arequestinfo.command);
  1034. //xseusform.memo1.lines.add(datetimetostr(aresponseinfo.lastmodified));
  1035. //xseusform.memo1.lines.add(datetimetostr(aresponseinfo.lastmodified));
  1036. { stime:=((now));
  1037. st:=arequestinfo.document;
  1038. st:=copy(st,_poslast('.',st),999);
  1039. if st='.ico' then exit;
  1040. if st<>'.htme' then
  1041. //requests for files not ending .htme are sent as is
  1042. begin
  1043. ifile:=ansilowercase(arequestinfo.document);
  1044. ifile:=_mapurltofile(ifile, x_commands.subt('mappings'));
  1045. try
  1046. aresponseinfo.ServeFile(Acontext, ifile);
  1047. finally
  1048. //resst.Clear;resst.Free;
  1049. end;
  1050. exit;
  1051. end;
  1052. connections:=connections+1;
  1053. xseusform.memo1.lines.add('start '+arequestinfo.document //+' id='+ arequestinfo.session.sessionid
  1054. //+ ':' + arequestinfo.session.content.text
  1055. + ' active='+inttostr(connections) +' mem used:'+inttostr(getheapstatus.totalallocated));
  1056. respa:=aresponseinfo;
  1057. try
  1058. if arequestinfo.session=nil then
  1059. xseusserver.server.createsession(acontext,aresponseinfo,arequestinfo);
  1060. assignhtml(output); //to be able to use "write/writeln" in subsequent programs
  1061. respa.WriteHeader;
  1062. xs:=txseus.create;
  1063. xso:=xs;
  1064. xs.httpinited:=false;
  1065. xs.x_session:=ttag(arequestinfo.session.content.objects[0]);
  1066. xs.ns:='xse:';
  1067. xs.request:=ARequestInfo;
  1068. xs.response:=AResponseInfo;
  1069. xs.doit;
  1070. finally
  1071. ohep:=getheapstatus.totalallocated;
  1072. xs.clear;
  1073. xs.free;
  1074. connections:=connections-1;
  1075. xseusform.memo1.lines.add(' stop '+ifile +' s.'
  1076. +inttostr(round((now-stime)*24*36000))
  1077. +' active calls= '+ inttostr(connections)
  1078. +' bytes allocated: '
  1079. +inttostr(getheapstatus.totalallocated)
  1080. );
  1081. end;
  1082. }
  1083. end;
  1084. procedure tsslserver.onCommandGet(AContext: TIdContext;
  1085. ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
  1086. var xs:txseus;st,ifile:string; resst:tstringlist;
  1087. //ReadCookie : TIdserverCookie;
  1088. //WriteCookie : TIdserverCookie;
  1089. i:integer;
  1090. threadelems:tlist;threadstates:tlist;stime:double;ohep:integer;
  1091. begin
  1092. logwrite('ssä');
  1093. //& xseusform.Memo1.lines.add('sslreq on port 443');
  1094. // if arequestinfo.session=nil then
  1095. // server.createsession(acontext,aresponseinfo,arequestinfo);
  1096. //aresponseinfo.writeheader;
  1097. doconnection(AContext, ARequestInfo,AResponseInfo);
  1098. //aresponseinfo.ContentText:=datetimetostr(now);
  1099. //AResponseInfo.WriteContent;
  1100. //xseusform.Memo1.lines.add('sslreq on port 432');
  1101. logwrite('did ssä');
  1102. end;
  1103. procedure txseusform.Status(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string);
  1104. begin
  1105. //& xseusform.Memo1.lines.add('-'+astatustext);
  1106. //writeln('-',astatustext);
  1107. end;
  1108. procedure Txseusform.GetPassword(var Password: String);
  1109. begin
  1110. Password := 'aaaa';
  1111. end;
  1112. initialization
  1113. { $i xserver.lrs}
  1114. end.