Delphi要实现的就是http协议的post方法
最重要的是这一部分
一下自定义http头,其实用Tstrings就简单多了
sends:='POST /regurl/regform.asp HTTP/1.1'+#13#10;
sends:=sends+'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*'+#13#10;
sends:=sends+'Accept-Language: zh-cn'+#13#10;
sends:=sends+'Content-Type: application/x-www-form-urlencoded'+#13#10;
sends:=sends+'Accept-Encoding: gzip, deflate'+#13#10;
sends:=sends+'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'+#13#10;
sends:=sends+'Host: db.sohu.com'+#13#10;
对于数据,必须经过nmurl编码。以下实现数据段(sendp就是数据段)
url.InputString := combobox2.Text;
sendp:='Step=Create&ClassKey='+url.Encode ;
url.inputstring := adoquery1.fieldvalues['文章名']+' 发布者:'+ adoquery1.fieldvalues['作者'] ;
sendp:=sendp+'&SiteName='+url.Encode;
url.inputstring:=edit5.text+'?id='+inttostr(adoquery1.fieldvalues['id']) ;
sendp:=sendp+'&URL='+url.Encode;
url.inputstring:= edit6.text;
sendp:=sendp+'&Description='+url.Encode;
sendp:=sendp+'&Keywords=';
url.inputstring:= edit3.text;
sendp:=sendp+'&EffDate=&ExpDate=&Contact=&EMail='+url.Encode+'&B1=%B5%DD%BD%BB';
sends:=sends+'Content-Length: '+inttostr(length(sendp))+#13#10;
sends:=sends+'Connection: Keep-Alive'+#13+#10+#13#10 +sendp;
clientsocket1.Socket.SendText(sends);