TIdHTTP请求GET请求

时间:2015-11-09 21:03:18

标签: c++ multithreading access-violation indy10 c++builder-6

尝试发送TIdHTTP::Get请求时,

EAccessViolation会抛出异常GET。实际上,我需要检索网页html内容。我决定使用TIdHTML + SSL套接字处理程序(因为我需要访问https)。 这是我的代码:

int Foo::bar()
{
    try
    {
        std::auto_ptr<TIdHTTP> idHttp(new TIdHTTP(NULL));
        std::auto_ptr<TIdSSLIOHandlerSocketOpenSSL>
                sslSock(new TIdSSLIOHandlerSocketOpenSSL(NULL));

        idHttp->HandleRedirects = true;        
        idHttp->IOHandler       = sslSock.get();

        AnsiString reply;
        // right there exception is being thrown
        reply = idHttp->Get("https://www.yandex.com/");

        ShowMessage(reply);
    }
    catch(EIdException & e)
    {            
        ShowMessage(e.Message);
    }
    catch(Exception & e)
    {
        ShowMessage(e.Message);
    }
}

实际上,有一件事:我的应用程序非常多线程。所有这些东西都在非主线程中执行。根据这个post,可能是关于IsMultiThread变量(但我已将其设置为true),所以我不知道为什么TIdHTTP每次尝试Read memory at 00000008

0 个答案:

没有答案
相关问题