Commit b3ae533e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

Added MIME type checking to ResProtocol::Start.

parent 5d0a292d
...@@ -549,7 +549,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ...@@ -549,7 +549,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
ResProtocol *This = PROTOCOL_THIS(iface); ResProtocol *This = PROTOCOL_THIS(iface);
DWORD grfBINDF = 0, len; DWORD grfBINDF = 0, len;
BINDINFO bindinfo; BINDINFO bindinfo;
LPWSTR url_dll, url_file, url; LPWSTR url_dll, url_file, url, mime;
HMODULE hdll; HMODULE hdll;
HRSRC src; HRSRC src;
HRESULT hres; HRESULT hres;
...@@ -564,10 +564,6 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ...@@ -564,10 +564,6 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo); IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
ReleaseBindInfo(&bindinfo); ReleaseBindInfo(&bindinfo);
/* FIXME:
* Implement MIME type checking
*/
len = strlenW(szUrl)+16; len = strlenW(szUrl)+16;
url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0); hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
...@@ -602,10 +598,10 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ...@@ -602,10 +598,10 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
} }
src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML); src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
HeapFree(GetProcessHeap(), 0, url);
if(!src) { if(!src) {
WARN("Could not find resource\n"); WARN("Could not find resource\n");
IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL); IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
HeapFree(GetProcessHeap(), 0, url);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
...@@ -621,6 +617,13 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ...@@ -621,6 +617,13 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
FreeLibrary(hdll); 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, IInternetProtocolSink_ReportData(pOIProtSink,
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE, BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
This->data_len, This->data_len); This->data_len, This->data_len);
......
...@@ -192,7 +192,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT ...@@ -192,7 +192,7 @@ static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT
expect_GetBindInfo = called_GetBindInfo = FALSE; 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; HRESULT hres;
...@@ -202,16 +202,12 @@ static void protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_mim ...@@ -202,16 +202,12 @@ static void protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_mim
expect_ReportData = TRUE; expect_ReportData = TRUE;
expect_hrResult = S_OK; expect_hrResult = S_OK;
expect_hr_win32err = FALSE; expect_hr_win32err = FALSE;
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0); hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
ok(hres == S_OK, "Start failed: %08lx\n", hres); ok(hres == S_OK, "Start failed: %08lx\n", hres);
ok(called_GetBindInfo, "expected GetBindInfo\n"); ok(called_GetBindInfo, "expected GetBindInfo\n");
if(is_mime_todo) { ok(called_ReportProgress, "expected ReportProgress\n");
todo_wine {
ok(called_ReportProgress, "expected ReportProgress\n");
}
}else {
ok(called_ReportProgress, "expected ReportProgress\n");
}
ok(called_ReportData, "expected ReportData\n"); ok(called_ReportData, "expected ReportData\n");
ok(called_ReportResult, "expected ReportResult\n"); ok(called_ReportResult, "expected ReportResult\n");
called_GetBindInfo = expect_GetBindInfo = FALSE; called_GetBindInfo = expect_GetBindInfo = FALSE;
...@@ -311,7 +307,7 @@ static void test_res_protocol(void) ...@@ -311,7 +307,7 @@ static void test_res_protocol(void)
ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres); ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres);
ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb); 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); hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb); ok(cb == 2, "cb=%lu expected 2\n", cb);
...@@ -323,7 +319,7 @@ static void test_res_protocol(void) ...@@ -323,7 +319,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol); hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); 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); hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_LockRequest(protocol, 0); hres = IInternetProtocol_LockRequest(protocol, 0);
...@@ -333,7 +329,7 @@ static void test_res_protocol(void) ...@@ -333,7 +329,7 @@ static void test_res_protocol(void)
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres); 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); hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0); hres = IInternetProtocol_Terminate(protocol, 0);
...@@ -350,12 +346,12 @@ static void test_res_protocol(void) ...@@ -350,12 +346,12 @@ static void test_res_protocol(void)
ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(hres == S_OK, "Read failed: %08lx\n", hres);
ok(cb == 2, "cb=%lu expected 2\n", cb); 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); hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres); 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); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(hres == S_OK, "Read failed: %08lx\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0); hres = IInternetProtocol_Terminate(protocol, 0);
...@@ -443,7 +439,7 @@ static void test_about_protocol(void) ...@@ -443,7 +439,7 @@ static void test_about_protocol(void)
ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres); ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
protocol_start(protocol, blank_url, FALSE); protocol_start(protocol, blank_url);
hres = IInternetProtocol_LockRequest(protocol, 0); hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
...@@ -453,7 +449,7 @@ static void test_about_protocol(void) ...@@ -453,7 +449,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol); hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); 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); hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
...@@ -463,7 +459,7 @@ static void test_about_protocol(void) ...@@ -463,7 +459,7 @@ static void test_about_protocol(void)
hres = IInternetProtocol_UnlockRequest(protocol); hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); 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); hres = IInternetProtocol_LockRequest(protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment