HTTP GET not working in Metro C++ app using IXMLHTTPRequest2 RRS feed

  • Question

  •  I am having trouble getting any sort of response or error when using IXMLHTTPRequest2 in our Metro C++ application. This is what I'm doing:

    HRESULT hr;
    DWORD dwStatus = 0;
    ComPtr<IXMLHTTPRequest2> xhr;
    ComPtr<CXMLHttpRequest2Callback> xhrMyCallback;
    ComPtr<IXMLHTTPRequest2Callback> xhrCallback;
    hr = CoCreateInstance(CLSID_FreeThreadedXMLHTTP60, nullptr,CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&xhr));
    hr = MakeAndInitialize<CXMLHttpRequest2Callback>(&xhrMyCallback);
    hr = xhrMyCallback.As(&xhrCallback);
    hr = xhr->Open(L"GET", L"http://www.google.com", xhrCallback.Get(), NULL, NULL, NULL, NULL);
    hr = xhr->Send(NULL, 0);
    hr = xhrMyCallback->WaitForComplete(&dwStatus);

    none of the callbacks ever return and WaitForSingleObjectEx (in CXMLHttpRequest2Callback::WaitForComplete) never returns.

    The strange thing is fiddler shows that I'm not only making the request, but I'm getting the full response (including http 200 OK), so the Send request worked, I just never find out one way or another in the code.

    Wednesday, June 24, 2015 9:08 PM