I have obtained valid session ID using IWebBrowser2 interface. Using this session ID I wish to download resources (*.jar files) from web server. However downloading resources using IWebBrowser2 pops up a dialog as shown in the below figure.
The original requirement is to transparently download resources without any user input. To achieve transparent download I tried using IWinHttpRequest interface and obtained session id. Code snippet is as shown below:
void DownloadResources(CString &strCookie) { //strCookie is of the from JSESSIONID=<ActualSession ID> CComPtr<IWinHttpRequest> l_ptrIWinHttpRequest = NULL; HRESULT hr = l_ptrIWinHttpRequest.CoCreateInstance(CLSID_WinHttpRequest); hr = l_ptrIWinHttpRequest->Open(_bstr_t(STRING_HTTP_VERB_GET), _T("Actual URL goes here"), _variant_t(VARIANT_FALSE)); hr = l_ptrIWinHttpRequest->SetRequestHeader((BSTR)_T("cookie" ,strCookie.Trim().AllocSysString()); _variant_t varEmpty; hr = l_ptrIWinHttpRequest->Send(varEmpty); if(SUCCEEDED(hr)) { long lVal = 0; hr = l_ptrIWinHttpRequest->get_Status(&lVal); //lVal obtained is equal to 401. } }
Can someone please elaborate as to what am I missing out in IWinHttpRequest. It is also fine if i can get a way to suppress the download prompt that appears using IWebBrowser2 interface.
Note: *.jar files are added filtered using web.xml file on web server.
Sumeet Bhatia --- [India]