Thread: HTTP post
View Single Post
  #4  
Old 08-19-2003, 01:38 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: HTTP post

Try this

procedure TForm1.SendPostData;
Var
aStream: TMemoryStream;
Params: TStringStream;
InternalHeaders: TIdHeaderList;
begin
aStream := TMemoryStream.create;
Params := TStringStream.create('');

try
with IdHTTP1 do
begin
Params.WriteString(URLEncode('teste=' + 'yes' + '&'));
Params.WriteString(URLEncode('name=' + 'ivan' + '&'));
Params.WriteString(URLEncode('number=' + '102'));
// You can change headers like this:
Request.ContentType := 'application/x-www-form-urlencoded';
// or set customheaders like this:
InternalHeaders := TIdHeaderList.Create;
InternalHeaders.Add ('User-Agent: WebTV');
Request.SetExtraHeaders(InternalHeaders);
InternalHeaders.Free;
try
Post('http://localhost/teste.asp', Params, aStream);
except
on E: Exception do
showmessage('Error encountered during POST: ' + E.Message);
end;
end;
aStream.WriteBuffer(#0' ', 1);
aStream.Position := 0;
Memo1.Lines.LoadFromStream(aStream);
except
end;
end;


Confusious say:
Never stand between fire hydrant and dog.

MB34
Reply With Quote