Added MIME type checking to ResProtocol::Start.

This commit is contained in:
Jacek Caban 2005-09-14 10:06:34 +00:00 committed by Alexandre Julliard
parent 5d0a292dd2
commit b3ae533e00
2 changed files with 21 additions and 22 deletions

View file

@ -549,7 +549,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
ResProtocol *This = PROTOCOL_THIS(iface);
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
LPWSTR url_dll, url_file, url;
LPWSTR url_dll, url_file, url, mime;
HMODULE hdll;
HRSRC src;
HRESULT hres;
@ -564,10 +564,6 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
ReleaseBindInfo(&bindinfo);
/* FIXME:
* Implement MIME type checking
*/
len = strlenW(szUrl)+16;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
@ -602,10 +598,10 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
}
src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
HeapFree(GetProcessHeap(), 0, url);
if(!src) {
WARN("Could not find resource\n");
IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
HeapFree(GetProcessHeap(), 0, url);
return HRESULT_FROM_WIN32(GetLastError());
}
@ -621,6 +617,13 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
FreeLibrary(hdll);
hres = FindMimeFromData(NULL, url_file, NULL, 0, NULL, 0, &mime, 0);
HeapFree(GetProcessHeap(), 0, url);
if(SUCCEEDED(hres)) {
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
CoTaskMemFree(mime);
}
IInternetProtocolSink_ReportData(pOIProtSink,
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
This->data_len, This->data_len);

View file

@ -192,7 +192,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT
expect_GetBindInfo = called_GetBindInfo = FALSE;
}
static void protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_mime_todo)
static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
{
HRESULT hres;
@ -202,16 +202,12 @@ static void protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_mim
expect_ReportData = TRUE;
expect_hrResult = S_OK;
expect_hr_win32err = FALSE;
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
ok(hres == S_OK, "Start failed: %08lx\n", hres);
ok(called_GetBindInfo, "expected GetBindInfo\n");
if(is_mime_todo) {
todo_wine {
ok(called_ReportProgress, "expected ReportProgress\n");
}
}else {
ok(called_ReportProgress, "expected ReportProgress\n");
}
ok(called_ReportProgress, "expected ReportProgress\n");
ok(called_ReportData, "expected ReportData\n");
ok(called_ReportResult, "expected ReportResult\n");
called_GetBindInfo = expect_GetBindInfo = FALSE;
@ -311,7 +307,7 @@ static void test_res_protocol(void)
ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres);
ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb);
protocol_start(protocol, blank_url, TRUE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb);
@ -323,7 +319,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
protocol_start(protocol, blank_url, TRUE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_LockRequest(protocol, 0);
@ -333,7 +329,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
protocol_start(protocol, blank_url, TRUE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0);
@ -350,12 +346,12 @@ static void test_res_protocol(void)
ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb);
protocol_start(protocol, blank_url, TRUE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
protocol_start(protocol, blank_url, TRUE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0);
@ -443,7 +439,7 @@ static void test_about_protocol(void)
ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
if(SUCCEEDED(hres)) {
protocol_start(protocol, blank_url, FALSE);
protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
@ -453,7 +449,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
protocol_start(protocol, test_url, FALSE);
protocol_start(protocol, test_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
@ -463,7 +459,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres);
protocol_start(protocol, res_url, FALSE);
protocol_start(protocol, res_url);
hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);