Dan wrote:

Before you start your request (before the get) you need to assign the receive stream:

HTTPCli.RcvdStream:=TMemoryStream.Create;

Then, in the OnRequestDone, as has been explained, you have the rcvdstream to read from:

var StringList: TStrings;
....
StringList:=TStringList.Create;
THTTPCli(Sender).RcvdStream.Seek(0,soBeginning);
StringList.LoadFromStream(THTTPCli(Sender).RcvdStream);
//Use StringList...
Stringlist.Free;

IMHO a slightly better solution:

HTTPCli.RcvdStream:=TStringStream.Create('');
..

// OnRequestDone event
StringList:=TStringList.Create;
StringList.Text:=TStringStream(THTTPCli(Sender).RcvdStream).DataString;
//Use StringList...
Stringlist.Free;



You are getting the access violation because you didnt allocate the stream before starting the request.


Dan.

----- Original Message ----- From: "Ann" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Wednesday, April 20, 2005 3:05 PM
Subject: Re: Re[4]: [twsocket] Multithreaded http...


I don't really know what to do with TMemoryStream... i need TStringList ...
the site isn't that big, so it should be any problem... But i still don't
know how do i convert the recived stream to TStringList... ;-(


----- Original Message ----- From: "Francois Piette" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Monday, April 18, 2005 9:23 AM
Subject: Re: Re[4]: [twsocket] Multithreaded http...



> > in On requestDone:
> > THttpCli(Sender).RcvdStream

> But how do i convert it to StringList ?

Convert the received stream to a string list ? Arno told you:
    AStream.Seek(0, sofromBeginning);
    StringList.LoadFromStream(AStream);

But if you want to convert to a string list for analysis, it is probably

not the most efficient way

to do that. You should probably use a TMemoryStream and direction use the

data in memory :


var
P : PChar; // Will point to HTML data (or whatever data you received)
N : Integer; // Will contains the number of bytes
begin
P := PChar((THttpCli(Sender).RcvdStream as TMemoryStream).Memory);
N := THttpCli(Sender).RcvdStream.Size;
// Now you can use P and N to analyse the document received. Very

fast.


// Don't forget to free the stream when processing is done or you'll have

a memory leak.


-- [EMAIL PROTECTED] http://www.overbyte.be


-- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be





-- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be





--
Marcello Vezzelli
CTO
Software Development Department
E-Works s.r.l.
tel. +39 059 2929081
fax +39 059 2925035
Direzionale 70 - Via Giardini 456/c
41100 Modena - Italy

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to