TIdMultiPartFormDataStream TIDHTTP的参数问题?
代码如下,利用TIDHTTP和TIdMultiPartFormDataStream post参数
para = “aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”;
TIdMultiPartFormDataStream *stream = new TIdMultiPartFormDataStream();
try{
stream->AddFormField("method",method);
stream->AddFormField("timestamp",timestampStr);
stream->AddFormField("para",para);
stream->Position = 0;
IdAntiFreeze1->OnlyWhenIdle = false;
IdHTTP1->Request->ContentType = "multipart/form-data";
IdHTTP1->Post("http://127.0.0.1//index.php",stream));
}__finally{
delete stream;
}
利用抓包工具查看,发现自动添加了“=”(70个自己就添加一个)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=
aaaaaaaaaaa
tidhttp c++Builder tidmultipartDataS
[解决办法]
多加两个参数试试:
stream->AddFormField("para", para, "iso-8859-1", "8bit");