Arthur Pires wrote:
>>> is there a way to execute an httpsend.httpmethod('GET',xxxxxxxxxxxx')
>>> with no http headers? usind tcp socket maybe?
>>
>> Yes. What is HTTP protocol? it is TCP socket connection where is
>> transferred datas by specified standard. HttpSend using
>> TTCPBlockSocket and build headers and other formal HTTP dependecies
>> around.
>>
>> So, if you want HTTP without headers, then use TTCPBlockSocket and
>> build all by yourself. ;)
>
> I don't even know how connect a tcp socket on synapse, connect method
> appers to have no effect =X
Let's take an analogue from a more close-to-earth situation.
You pick up a telephone and dial your friends number. He picks up the telephone
when it rings, but neither of you speaks anything. You and your friend are
connected, but you're not communicating before either of you starts talking. If
this goes on for long enough, you or your friend is bound to get fed up and
close the telephone; this is what happens when the connection times out. In the
world of Internet, the communication is done by protocols. The connecting is
usually easy; that's only where the problems start... after that you still need
to see if you and the one being called to are even speaking the same language :)
So. After you've connected, you need to start talking.
Here's a bit of code I did absolutely no testing with (not even to see if it
compiles or not - actually, I don't have Synapse on this machine I'm at at the
moment) but hopefully it will give you a rough idea of how this is handled:
<<CODE BEGIN>>
program HttpStreamer;
{$APPTYPE CONSOLE}
uses
SysUtils, blcksock, Classes;
var
bs: TTcpBlockSocket;
s: String;
data: TMemoryStream;
begin
bs := TTcpBlockSocket.Create;
try
bs.Connect('192.168.0.2','80'); // Just an example address
WriteLn('Connected...');
bs.SendString('GET / HTTP/1.0');
bs.SendString(''); // Empty line meand "my talking is done"
WriteLn('Request sent...');
while bs.RecvString(30000) <> '' do begin { bypass headers } end;
WriteLn('Headers received (and bypassed)...');
WriteLn('Now, we are going to write out # for every kB we receive...');
// That's it, those were the headers...
data := TMemoryStream.Create;
try
// Now, we can start receiving data...
while bs.Connected do
begin
bs.RecvStreamSize(data, 30000, 1024);
Write('#'); // As promised, 1kB received, output # ...
// Now we have received 1024 bytes of data, what should we do with it?
data.Seek(0, soFromBeginning); // Just rewind it and be done with it :)
// If we still happen to be connected, the loop continues...
end;
finally
FreeAndNil(data);
end;
finally
FreeAndNil(bs);
end;
end.
<<CODE DONE!>>
Hopefully, if I made a major blunder, someone will correct me out :)
--
Markku Uttula
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public