大家好,我想用C++ Builder的Indy做一个通过代理服务器连接一个servlet的程序,我是如下做的,不知道是否正确,请高手指点,
大家好,我想用C++ Builder的Indy做一个通过代理服务器连接一个servlet的程序,我是如下做的,不知道是否正确,请高手指点,可我总是遇到返回错误,要不说connection
time out,或者说需要用户验证名称与密码,可我已经赋值了啊,说到地我对Indy的使用方法不是很了解,也许是哪些参数没有设置或者设置的不对,谁能提供一个标准的用TIdHTTP通过代理连接服务器Servlet的程序,谢谢.
TIdHTTP * http = new TIdHTTP(Application);
bool ret = GetServerURL();
AnsiString url = "";
TStrings *formData = new TStringList();
formData->Add("ProductID="+Product.m_ProductIDstr);
char buf[1024];
memset(buf,0,1024);
formData->Add("SoftwareNum="+AnsiString(itoa (Product.m_SoftwareNum,buf,10)));
TStream *receive = new TMemoryStream();
if(!ret)
{
MessageDlg("ERR",mtError,TMsgDlgButtons() << mbOK,0);
return;
}else
{
url = ServerURL+"legend/servlet/search";
}
try{
//http->Request->URL = url;
http->Request->ContentType = "application/x-www-form-urlencoded";
http->ProxyParams->ProxyUsername = DefaultProxy->m_Username;
http->ProxyParams->ProxyPassword = DefaultProxy->m_Password;
http->ProxyParams->ProxyServer = DefaultProxy->m_IP;
http->ProxyParams->ProxyPort = DefaultProxy->m_Port;
//http->ProxyParams->BasicAuthentication = true;
http->Post(url,formData,receive);
}catch(const Exception &E)
{
ShowMessage(AnsiString(E.ClassName())+ " == " + E.Message);
}
delete formData;