D
drawpharos
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码,从运行结果看,没有Post任何数据给Web.
环境:WinXP Pro /C++Builder 6,BCB6自带的Indy控件
[red]问题已解决!只要设 [blue]IdHTTP1->Request->ContentType = 'application/x-www-form-urlencoded'[/blue]即可[][/red]
环境:WinXP Pro /C++Builder 6,BCB6自带的Indy控件
代码:
int TForm1::CheckWeb(String sHost)
{
TMemoryStream *ovData=new TMemoryStream();
TStringStream *ovResult=new TStringStream("");
AnsiString rtBody;
int rtCode;
try
{
ovData->Write("userid=user&password=pass",26);
ovData->Position=0;
ovResult->Position=0;
IdHTTP1->Post(sHost,ovData,ovResult);
ovResult->Position=0;
rtBody=ovResult->ReadString(ovResult->Size);
if (rtBody.SubString(0,39)=="<?xml version=/"1.0/" encoding=/"GB2312/"?>")
rtCode=0;
else
rtCode=1;
}
catch(...)
{
rtCode=2;
}
ovData->Free();
ovResult->Free();
return rtCode;
}