urlmon: Use CoInternetParseIUri instead of IUri::GetPath in file protocol handler implementation.

This commit is contained in:
Jacek Caban 2011-06-25 19:04:16 +02:00 committed by Alexandre Julliard
parent 8f3c3ca35c
commit 7ccbbd86ba
2 changed files with 24 additions and 5 deletions

View File

@ -245,12 +245,13 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
DWORD grfPI, HANDLE *dwReserved) DWORD grfPI, HANDLE *dwReserved)
{ {
FileProtocol *This = impl_from_IInternetProtocolEx(iface); FileProtocol *This = impl_from_IInternetProtocolEx(iface);
WCHAR path[MAX_PATH];
BINDINFO bindinfo; BINDINFO bindinfo;
DWORD grfBINDF = 0; DWORD grfBINDF = 0;
DWORD scheme; DWORD scheme, size;
LPWSTR mime = NULL; LPWSTR mime = NULL;
WCHAR null_char = 0; WCHAR null_char = 0;
BSTR path, url; BSTR url;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink, TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink,
@ -288,14 +289,14 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char); IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
hres = IUri_GetPath(pUri, &path); size = 0;
hres = CoInternetParseIUri(pUri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0);
if(FAILED(hres)) { if(FAILED(hres)) {
ERR("GetPath failed: %08x\n", hres); WARN("CoInternetParseIUri failed: %08x\n", hres);
return report_result(pOIProtSink, hres, 0); return report_result(pOIProtSink, hres, 0);
} }
hres = open_file(This, path, pOIProtSink); hres = open_file(This, path, pOIProtSink);
SysFreeString(path);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -2447,6 +2447,24 @@ static void test_file_protocol_url(LPCWSTR url)
IUri_Release(uri); IUri_Release(uri);
IInternetProtocolEx_Release(protocolex); IInternetProtocolEx_Release(protocolex);
hres = pCreateUri(url, 0, 0, &uri);
ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocolEx, (void**)&protocolex);
ok(hres == S_OK, "Could not get IInternetProtocolEx: %08x\n", hres);
if(file_protocol_start(NULL, NULL, protocolex, uri, TRUE)) {
hres = IInternetProtocolEx_Read(protocolex, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08x\n", hres);
hres = IInternetProtocolEx_LockRequest(protocolex, 0);
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
hres = IInternetProtocolEx_UnlockRequest(protocolex);
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
}
IUri_Release(uri);
IInternetProtocolEx_Release(protocolex);
}else { }else {
win_skip("Skipping file protocol StartEx tests\n"); win_skip("Skipping file protocol StartEx tests\n");
} }