Hi,
I have problem with LNet httpclient. I want get html text of some page.
I found examples in LNet package. However, my program as well as examples of the demo throw the error: "Error on connect: connection refused"
This is my code:
procedure TForm1.Button1Click(Sender: TObject);
var
S: TStrings;
aHost,
aURI: String;
aPort: Word;
begin
HTTPBuffer := '';
DecomposeURL(Edit1.Text, aHost, aURI, aPort);
httpclient.Host := aHost;
httpclient.URI := aURI;
httpclient.Port := aPort;
httpclient.SendRequest;
end;
procedure TForm1.httpclientDoneInput(ASocket: TLHTTPClientSocket);
begin
ASocket.Disconnect;
end;
procedure TForm1.httpclientError(const msg: string; aSocket: TLSocket);
begin
MessageDlg(msg, mtError, [mbOK], 0);
end;
function TForm1.httpclientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar;
ASize: integer): integer;
var
oldLength: dword;
begin
oldLength := Length(HTTPBuffer);
setlength(HTTPBuffer,oldLength + ASize);
move(ABuffer^,HTTPBuffer[oldLength + 1], ASize);
Memo1.Text := HTTPBuffer;
Memo1.SelStart := Length(HTTPBuffer);
AppendToMemo(Memo1, IntToStr(ASize) + '...');
Result := aSize; // tell the http buffer we read it all
end;
procedure TForm1.AppendToMemo(aMemo: TMemo; const aText: string);
begin
aMemo.Append(aText);
aMemo.SelStart := Length(aMemo.Text);
end;
Regards.
Lazarus Revision 21752 from 2009-09-18. Windows Vista 32bit with SP1. Testet on LNet 0.6.2 and 0.6.3 (SVN version)