1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| begin
Inc(FHttpFinish);
if (FHttpProcess>0) then Dec(FHttpProcess);
case ErrCode of
httperrNoError: Inc(FHttpSuccess);
httperrAborted: Inc(FHttpAbort);
else
Inc(FHttpAbort);
end;
MyHttp:=(Sender as TMyHttp);
MyURL:=(MyHttp.Data as TMyURL);
Stream:=MyHttp.RcvdStream;
MyHttp.Data:=nil;
MyHttp.URL:='';
MyHttp.RcvdStream:=nil;
MyHttp.SendStream:=nil;
// Obligation de verifier auparavent, car le Abort meme lorsqu'aucune requete
// n'a eu lieu, genere malgre tout l'evenement OnRequestDone
if Assigned(MyURL) then
begin
if (ErrCode=httperrNoError) then
begin
FN:='';
SessionId:='';
c:=nil;
Stream.Seek(0, soFromEnd);
Stream.Write(c, 1);
Stream.Seek(0, soFromBeginning);
Buffer:=TMemoryStream(Stream).Memory;
...
...
case IndexOfArray(Extension, ['html', 'plain', 'rtf', 'pdf', 'doc', 'ppt', 'xls', 'ps']) of
0 : // HTML
Begin
...
end;
...
2 : // RICHTEXT (RTF)
Begin
slRTF:=TStringList.create;
Try
slRTF.LoadFromStream(Stream);
RTF:=slRTF.Text;
s:=RTFtoText(RTF, True, True, 0);
Finally
slRTF.Free;
End;
// Calcul du nom du lien de la ressource
Hash:=RandomString(8, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');
while FileExists(Path+'\rtf\'+Hash+'.'+Extension) or Assigned(Data.Patents.FindOfNumber(Hash)) do
Hash:=RandomString(8, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');
F:=TFileStream.Create(Path+'\rtf\'+Hash+'.'+Extension, fmCreate);
try
F.CopyFrom(Stream, 0);
finally
F.Free;
end;
if s<>'' then
Begin
F:=TFileStream.Create(Path+'\rtf\'+Hash+'.txt', fmCreate);
try
F.Write(PChar(s)^, Length(s));
finally
F.Free;
end;
End;
.... |
Partager