Board index » delphi » can't receive TidHttp' Posted Data

can't receive TidHttp' Posted Data

I write my code using TIdHttp.
But I think Post Method don't work.(the same result using Get Method. i.e.
can't receive the data)
Can anyone tell met my mistake in code.
I tried two kinds of
1)
var
  PostDataStream : TStringStream;
  s : TStringList;
begin
   PostDataStream := TStringStream.Create('') ;
   s := TStringList.Create ;
  try
   s.Add('name=test');
   IdHttp1.PostData := s; file://or IdHttp1.PostData.Text := 'name=test';
   IdHttp1.Post(EdtUrl.Text,PostDataStream);
   MoContent.Lines.Text := PostDataStream.DataString   ;
 finally
   PostDataStream.Free;
end;

2)
var
  PostDataStream : TStringStream;
  SourceData : TStringStream;
begin
   PostDataStream := TStringStream.Create('') ;
   SourceData := TStringStream.Create('name=test');
try
    IdHttp1.PostFromStream(EdtUrl.text, SourceData, PostDataStream);
   MoContent.Lines.Text := PostDataStream.DataString   ;
finally
  SourceData.Free;
   PostDataStream.Free;
end;

The above two kinds of try was useless.
The Web server can't receive the PostData(name=test).

What's my mistake?

I use windows 2000 sever with IIS5.0
thank you.

 

Re:can't receive TidHttp' Posted Data


the key is

Content-Type: application/x-www-form-urlencoded

any way thank you everybody.

Quote
"YK, Kwon" <ty...@idanet.com> wrote in message

news:8leuo1$ct17@bornews.borland.com...
Quote
> I write my code using TIdHttp.
> But I think Post Method don't work.(the same result using Get Method. i.e.
> can't receive the data)
> Can anyone tell met my mistake in code.
> I tried two kinds of
> 1)
> var
>   PostDataStream : TStringStream;
>   s : TStringList;
> begin
>    PostDataStream := TStringStream.Create('') ;
>    s := TStringList.Create ;
>   try
>    s.Add('name=test');
>    IdHttp1.PostData := s; file://or IdHttp1.PostData.Text := 'name=test';
>    IdHttp1.Post(EdtUrl.Text,PostDataStream);
>    MoContent.Lines.Text := PostDataStream.DataString   ;
>  finally
>    PostDataStream.Free;
> end;

> 2)
> var
>   PostDataStream : TStringStream;
>   SourceData : TStringStream;
> begin
>    PostDataStream := TStringStream.Create('') ;
>    SourceData := TStringStream.Create('name=test');
> try
>     IdHttp1.PostFromStream(EdtUrl.text, SourceData, PostDataStream);
>    MoContent.Lines.Text := PostDataStream.DataString   ;
> finally
>   SourceData.Free;
>    PostDataStream.Free;
> end;

> The above two kinds of try was useless.
> The Web server can't receive the PostData(name=test).

> What's my mistake?

> I use windows 2000 sever with IIS5.0
> thank you.

Other Threads