大致了解:

1. get是从服务器上获取数据,post是向服务器传送数据。
get 和 post只是一种传递数据的方式,get也可以把数据传到服务器,他们的本质都是发送请求和接收结果。只是组织格式和数据量上面有差别,http协议里面有介绍
  2. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到。post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址。用户看不到这个过程。
因为get设计成传输小数据,而且最好是不修改服务器的数据,所以浏览器一般都在地址栏里面可以看到,但post一般都用来传递大数据,或比较隐私的数据,所以在地址栏看不到,能不能看到不是协议规定,是浏览器规定的。
3. 对于get方式,服务器端用Request.QueryString获取变量的值,对于post方式,服务器端用Request.Form获取提交的数据。
没明白,怎么获得变量和你的服务器有关,和get或post无关,服务器都对这些请求做了封装
  4. get传送的数据量较小,不能大于2KB。post传送的数据量较大,一般被默认为不受限制。但理论上,IIS4中最大量为80KB,IIS5中为100KB。
post基本没有限制,我想大家都上传过文件,都是用post方式的。只不过要修改form里面的那个type参数
  5. get安全性非常低,post安全性较高。
如果没有加密,他们安全级别都是一样的,随便一个监听器都可以把所有的数据监听到,不信你自己下一个监听网络资源的软件,

================================================================================================

1.

 var
Response: TStringStream;
PostData: TStrings;
....

PostData:=TStringlist.Create;
PostData.Add(‘id=2);
IdHTTP1.Request.ContentType := ‘application/x-www-form-urlencoded‘;
idHttp1.Post(‘http://www.****.com/);
memo1.Text:=Response.DataString;

2.

var
  Param:TStringList;
  RStream:TMemoryStream;
begin
  Param:=TStringList.Create;
  RStream:=TMemoryStream.Create;

  Param.Add('waybills='+edtshippingsn.Text);
  Param.Add('verifycode='+edtcode.Text);

try 
   IdHTTP1.Post('http://www.exp.com/myquery/queryBill.action?locale=zh_CN', Param,RStream);  
   RStream.SaveToFile('Cache\result.html');
finally
    RStream.Free;
  end;

end;

3.

var
  Params: TStrings;
begin
      Params:=TStringList.Create;
      try
          Params.Add('name='+Edit1.Text);
          Params.Add('age='+Edit2.Text);
          IdHTTP1.Post('http://127.0.0.1/ok.asp',Params);
      finally
          Params.Free;
      end;
end;

4.Delphi Idhttp的get和post方法

Post

var
  Param:TStringList;
  RStream:TStringStream;
begin
  Param:=TStringList.Create;
  RStream:=TStringStream.Create('');
 
  Param.Add('username=showlee000');
  Param.Add('normModPsp=********');
  Param.Add('mem_pass=true');
  IdHTTP1.Post('Http://URL',
              Param,RStream);

  memo1.Text:=RStream.DataString;

Get

idHttp1.Request.CustomHeaders.Text :=
  'Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'+
  #13+#10+'Referer:http://url'+
  #13+#10+'Accept-Language: zh-CN' +
  #13+#10+'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)'+
  #13+#10+'Accept-Encoding: gzip, deflate'+
  #13+#10+'Host: ***'+
  #13+#10+'Connection: Keep-Alive'+
  #13+#10+'Authorization: Basic *****=';
  IdHTTP1.get('http://url');

5.

R := IdHTTP.Post(URL, ParaList); 

6.

你说的是第二步了,请问   第一步   怎样把用户名,密码   放到登录页然后Post回去
IdHTTP1.Get(Edit1.Text);
param.Add(userid=test1 ');
param.Add( 'pswd=123 ');
param.Add( 'Send=1 ');   //我看到别人写的是不是相当于提交,不知我该写什么?
IdHTTP1.Post(Edit1.Text,param,FileStream   );

//FileleStream     时返回来的网页信息吧 

7.

==============网上抄的。
  PostDataStream := TStringStream.Create('');
  ParamData := TStringStream.Create('');
  ParamStr := TStringList.Create;
 // ParamData.WriteString('name=123&Submit=%E6%8F%90%E4%BA%A4'); //这样写是不行的。但是网上资料都是这样写。
  ParamStr.Add('name=1203');
  ParamStr.Add('Submit=%E6%8F%90%E4%BA%A4');
  IdHTTP.Post('http://127.0.0.1/reg.asp', ParamStr, PostDataStream); //第一个参数写错会提示404错误,表示网页不存在。例如把reg.asp改为rr.asp。

 

//Html := IdHTTP.Post('http://127.0.0.1/reg.asp', ParamStr); //也可以这样写,都是对的。
  postdatastream.Position:=0;
  memo1.Text:=Utf8ToAnsi(postdatastream.DataString); //不加Utf8ToAnsi这个的话,会返回乱码。
  PostDataStream.Free;
  ParamData.Free;

=========================================

我自己用的:

var

  top_result: string;

  MyTopLogisticsPartnerPostList: TStrings;

---------------

top_result := MyIdHTTP.Post(top_url+'TopLogisticsPartner/Insert.php',MyTopLogisticsPartnerPostList);

----POST不常用以后有时间了再研究-----上面都是我搜了百贴总结的。。

                MyTopLogisticsPartnerPostList := TStringList.Create;
                try
                  MyTopLogisticsPartnerPostList.Add('top_company_code='+MyTopCompanyCodeList[I]);
                  MyTopLogisticsPartnerPostList.Add('top_company_name='+top_company_name);
                  MyTopLogisticsPartnerPostList.Add('top_target_id='+top_target_id);
                  MyTopLogisticsPartnerPostList.Add('top_cover_remark='+'服务器没有返回此快递公司数据');
                  MyTopLogisticsPartnerPostList.Add('top_uncover_remark='+'服务器没有返回此快递公司数据');

                  top_result := MyIdHTTP.Post(top_url+'TopLogisticsPartner/Insert.php',MyTopLogisticsPartnerPostList);

                  if top_result = 'true' then
                  begin
                    True_mmo.Lines.Add(top_target_id+'-----'+top_result);
                  end else begin
                    False_mmo.Lines.Add(top_target_id+'-----'+top_result);
                  end;
                finally
                  MyTopLogisticsPartnerPostList.Free;
                end

====================================

2012.08.15.--补充

对于get 中文要进行 url编码

对于post中文不需要进行URL编码

posted on 2012-08-14 11:52  del88  阅读(56)  评论(0编辑  收藏  举报