wxHTTPBuilder problem on Windows

Julian Smart julian at anthemion.co.uk
Thu Nov 1 04:43:43 PDT 2007


Hi,

I'm trying wxHTTPEngine/wxHTTPBuilder on Windows with wxWidgets 2.8.6 
(Unicode, VC++ 6) and the sample fails to download anything (it times 
out).  Similarly a simple piece of test code using wxHTTPBuilder times 
out, whereas the equivalent direct wxHTTP usage does download a file 
fine (but I expect complications when it comes to using threads).

This fails (GetInputStream hangs):

            wxString indexFile = 
wxT("http://www.writerscafe.co.uk/download.htm");

            wxHTTPBuilder* http = new wxHTTPBuilder();
            http->InitContentTypes();
            http->SetTimeout(10);
          
            wxInputStream* inputStream = http->GetInputStream(indexFile);
            if (inputStream)
            {
                char szBuf[1000];
                inputStream->Read(szBuf, 1000);
            }

            delete inputStream;

whereas this works:

            wxHTTP get;
            get.SetTimeout(10);
           
            while (!get.Connect(_T("www.writerscafe.co.uk")))
                wxSleep(5);
           
            wxInputStream *httpStream = 
get.GetInputStream(_T("/download.htm"));
           
            if (get.GetError() == wxPROTO_NOERR)
            {
                wxString res;
                wxStringOutputStream out_stream(&res);
                httpStream->Read(out_stream);
               
                wxMessageBox(res);
            }
            else
            {
                wxMessageBox(_T("Unable to connect!"));
            }
           
            wxDELETE(httpStream);
            get.Close();

I should probably be using wxCURL, but I was hoping to get away with 
something lighter, and I thought wxHTTPBuilder would help with using a 
separate thread. Is the above problem known?

Thanks,

Julian

-- 
Julian Smart, Anthemion Software Ltd.
28/5 Gillespie Crescent, Edinburgh, Midlothian, EH10 4HU
www.anthemion.co.uk | +44 (0)131 229 5306
Tools for writers: www.writerscafe.co.uk
wxWidgets RAD:     www.anthemion.co.uk/dialogblocks





More information about the wx-users mailing list