2005-09-06 11:27:04 +02:00
|
|
|
/*
|
2007-01-23 23:33:38 +01:00
|
|
|
* Copyright 2005-2007 Jacek Caban for CodeWeavers
|
2005-09-06 11:27:04 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-09-06 11:27:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2006-09-29 12:45:44 +02:00
|
|
|
#define CONST_VTABLE
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
#include <wine/test.h>
|
|
|
|
#include <stdarg.h>
|
2007-12-24 12:43:35 +01:00
|
|
|
#include <stdio.h>
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "urlmon.h"
|
2008-05-10 14:20:43 +02:00
|
|
|
#include "wininet.h"
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
#define DEFINE_EXPECT(func) \
|
|
|
|
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
|
|
|
|
|
|
|
|
#define SET_EXPECT(func) \
|
|
|
|
expect_ ## func = TRUE
|
|
|
|
|
2008-01-31 18:18:49 +01:00
|
|
|
#define CHECK_EXPECT2(func) \
|
2005-12-19 09:57:25 +01:00
|
|
|
do { \
|
2008-01-31 18:18:49 +01:00
|
|
|
ok(expect_ ##func, "unexpected call " #func "\n"); \
|
2005-12-19 09:57:25 +01:00
|
|
|
called_ ## func = TRUE; \
|
|
|
|
}while(0)
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2008-01-31 18:18:49 +01:00
|
|
|
#define CHECK_EXPECT(func) \
|
2005-12-19 09:57:25 +01:00
|
|
|
do { \
|
2008-01-31 18:18:49 +01:00
|
|
|
CHECK_EXPECT2(func); \
|
|
|
|
expect_ ## func = FALSE; \
|
2005-12-19 09:57:25 +01:00
|
|
|
}while(0)
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
#define CHECK_CALLED(func) \
|
2005-12-19 09:57:25 +01:00
|
|
|
do { \
|
|
|
|
ok(called_ ## func, "expected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2007-07-19 02:59:06 +02:00
|
|
|
#define CHECK_NOT_CALLED(func) \
|
|
|
|
do { \
|
|
|
|
ok(!called_ ## func, "unexpected " #func "\n"); \
|
|
|
|
expect_ ## func = called_ ## func = FALSE; \
|
|
|
|
}while(0)
|
|
|
|
|
2007-07-19 02:58:32 +02:00
|
|
|
#define CLEAR_CALLED(func) \
|
|
|
|
expect_ ## func = called_ ## func = FALSE
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
DEFINE_EXPECT(GetBindInfo);
|
|
|
|
DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
DEFINE_EXPECT(ReportProgress_DIRECTBIND);
|
2007-07-19 03:00:20 +02:00
|
|
|
DEFINE_EXPECT(ReportProgress_RAWMIMETYPE);
|
2005-12-31 13:32:40 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE);
|
|
|
|
DEFINE_EXPECT(ReportProgress_CONNECTING);
|
2005-10-29 12:28:47 +02:00
|
|
|
DEFINE_EXPECT(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
2005-12-19 09:57:25 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
|
2007-01-23 19:36:38 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID);
|
2007-12-24 12:43:35 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_COOKIE_SENT);
|
|
|
|
DEFINE_EXPECT(ReportProgress_REDIRECTING);
|
2009-01-12 18:20:06 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_ENCODING);
|
|
|
|
DEFINE_EXPECT(ReportProgress_ACCEPTRANGES);
|
2009-01-20 02:56:46 +01:00
|
|
|
DEFINE_EXPECT(ReportProgress_PROXYDETECTING);
|
2005-09-06 11:27:04 +02:00
|
|
|
DEFINE_EXPECT(ReportData);
|
|
|
|
DEFINE_EXPECT(ReportResult);
|
2005-12-31 13:32:40 +01:00
|
|
|
DEFINE_EXPECT(GetBindString_ACCEPT_MIMES);
|
|
|
|
DEFINE_EXPECT(GetBindString_USER_AGENT);
|
2007-07-21 02:55:32 +02:00
|
|
|
DEFINE_EXPECT(GetBindString_POST_COOKIE);
|
2005-12-31 13:32:40 +01:00
|
|
|
DEFINE_EXPECT(QueryService_HttpNegotiate);
|
2007-01-23 19:36:38 +01:00
|
|
|
DEFINE_EXPECT(QueryService_InternetProtocol);
|
2009-04-07 12:22:14 +02:00
|
|
|
DEFINE_EXPECT(QueryService_HttpSecurity);
|
2005-12-31 13:32:40 +01:00
|
|
|
DEFINE_EXPECT(BeginningTransaction);
|
|
|
|
DEFINE_EXPECT(GetRootSecurityId);
|
|
|
|
DEFINE_EXPECT(OnResponse);
|
|
|
|
DEFINE_EXPECT(Switch);
|
2007-12-24 12:43:35 +01:00
|
|
|
DEFINE_EXPECT(Continue);
|
2007-01-23 19:36:38 +01:00
|
|
|
DEFINE_EXPECT(CreateInstance);
|
|
|
|
DEFINE_EXPECT(Start);
|
|
|
|
DEFINE_EXPECT(Terminate);
|
|
|
|
DEFINE_EXPECT(Read);
|
2007-01-23 23:33:38 +01:00
|
|
|
DEFINE_EXPECT(SetPriority);
|
2007-12-24 12:43:35 +01:00
|
|
|
DEFINE_EXPECT(LockRequest);
|
|
|
|
DEFINE_EXPECT(UnlockRequest);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2005-12-19 09:57:25 +01:00
|
|
|
static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
|
|
|
|
static const WCHAR index_url[] =
|
|
|
|
{'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
static const WCHAR acc_mimeW[] = {'*','/','*',0};
|
|
|
|
static const WCHAR user_agentW[] = {'W','i','n','e',0};
|
|
|
|
static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
|
|
|
|
static const WCHAR hostW[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
|
|
|
|
static const WCHAR winehq_ipW[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
|
2007-12-28 14:54:48 +01:00
|
|
|
static const WCHAR emptyW[] = {0};
|
2007-12-24 12:43:35 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
static HRESULT expect_hrResult;
|
2007-01-23 19:36:38 +01:00
|
|
|
static LPCWSTR file_name, http_url, expect_wsz;
|
2009-03-04 19:06:06 +01:00
|
|
|
static IInternetProtocol *async_protocol = NULL;
|
2007-07-21 02:55:32 +02:00
|
|
|
static BOOL first_data_notif = FALSE, http_is_first = FALSE,
|
|
|
|
http_post_test = FALSE;
|
2007-12-24 12:43:35 +01:00
|
|
|
static int state = 0, prot_state;
|
|
|
|
static DWORD bindf = 0, ex_priority = 0;
|
2007-12-28 14:54:48 +01:00
|
|
|
static IInternetProtocol *binding_protocol;
|
2007-01-23 19:36:38 +01:00
|
|
|
static IInternetBindInfo *prot_bind_info;
|
2007-12-24 12:43:35 +01:00
|
|
|
static IInternetProtocolSink *binding_sink;
|
2007-01-23 19:36:38 +01:00
|
|
|
static void *expect_pv;
|
2007-12-24 12:43:35 +01:00
|
|
|
static HANDLE event_complete, event_complete2;
|
|
|
|
static BOOL binding_test;
|
|
|
|
static PROTOCOLDATA protocoldata, *pdata;
|
2007-12-28 14:54:48 +01:00
|
|
|
static DWORD prot_read;
|
2009-04-07 12:22:14 +02:00
|
|
|
static BOOL security_problem = FALSE;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
static enum {
|
|
|
|
FILE_TEST,
|
2007-01-13 12:46:06 +01:00
|
|
|
HTTP_TEST,
|
2009-01-12 18:20:06 +01:00
|
|
|
HTTPS_TEST,
|
2009-03-04 19:06:06 +01:00
|
|
|
FTP_TEST,
|
2007-01-23 19:36:38 +01:00
|
|
|
MK_TEST,
|
|
|
|
BIND_TEST
|
2005-12-31 13:32:40 +01:00
|
|
|
} tested_protocol;
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
static const WCHAR protocol_names[][10] = {
|
|
|
|
{'f','i','l','e',0},
|
|
|
|
{'h','t','t','p',0},
|
2009-03-04 19:06:06 +01:00
|
|
|
{'h','t','t','p','s',0},
|
|
|
|
{'f','t','p',0},
|
2007-12-24 12:43:35 +01:00
|
|
|
{'m','k',0},
|
|
|
|
{'t','e','s','t',0}
|
|
|
|
};
|
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
static const WCHAR binding_urls[][130] = {
|
2007-12-24 12:43:35 +01:00
|
|
|
{'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
|
|
|
|
{'h','t','t','p',':','/','/','t','e','s','t','/','t','e','s','t','.','h','t','m','l',0},
|
2009-03-04 19:06:06 +01:00
|
|
|
{'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
|
|
|
|
'.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
|
|
|
|
{'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
|
|
|
|
'/','p','u','b','/','o','t','h','e','r',
|
|
|
|
'/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
|
2007-12-24 12:43:35 +01:00
|
|
|
{'m','k',':','t','e','s','t',0},
|
|
|
|
{'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *debugstr_w(LPCWSTR str)
|
|
|
|
{
|
|
|
|
static char buf[512];
|
|
|
|
if(!str)
|
|
|
|
return "(null)";
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debugstr_guid(REFIID riid)
|
|
|
|
{
|
|
|
|
static char buf[50];
|
|
|
|
|
|
|
|
sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|
|
|
riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
|
|
|
|
riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
|
|
|
|
riid->Data4[5], riid->Data4[6], riid->Data4[7]);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2009-01-12 18:20:06 +01:00
|
|
|
static int strcmp_wa(LPCWSTR strw, const char *stra)
|
|
|
|
{
|
|
|
|
WCHAR buf[512];
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
|
|
|
return lstrcmpW(strw, buf);
|
|
|
|
}
|
|
|
|
|
2009-04-07 12:22:14 +02:00
|
|
|
static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)
|
|
|
|
|| IsEqualGUID(&IID_IHttpSecurity, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity* iface, REFGUID rguidReason, HWND *phwnd)
|
|
|
|
{
|
|
|
|
trace("HttpSecurity_GetWindow\n");
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
|
|
|
|
{
|
|
|
|
trace("Security problem: %u\n", dwProblem);
|
|
|
|
ok(dwProblem == ERROR_INTERNET_SEC_CERT_REV_FAILED, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem);
|
|
|
|
|
|
|
|
/* Only retry once */
|
|
|
|
if (security_problem)
|
|
|
|
return E_ABORT;
|
|
|
|
|
|
|
|
security_problem = TRUE;
|
|
|
|
SET_EXPECT(BeginningTransaction);
|
|
|
|
|
|
|
|
return RPC_E_RETRY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IHttpSecurityVtbl HttpSecurityVtbl = {
|
|
|
|
HttpSecurity_QueryInterface,
|
|
|
|
HttpSecurity_AddRef,
|
|
|
|
HttpSecurity_Release,
|
|
|
|
HttpSecurity_GetWindow,
|
|
|
|
HttpSecurity_OnSecurityProblem
|
|
|
|
};
|
|
|
|
|
|
|
|
static IHttpSecurity http_security = { &HttpSecurityVtbl };
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2005-12-31 13:32:40 +01:00
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)
|
|
|
|
|| IsEqualGUID(&IID_IHttpNegotiate, riid)
|
|
|
|
|| IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
2005-09-06 11:27:04 +02:00
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
ok(0, "unexpected call\n");
|
2005-09-06 11:27:04 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
|
|
|
|
LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
|
|
|
|
{
|
2007-07-21 02:55:32 +02:00
|
|
|
LPWSTR addl_headers;
|
|
|
|
|
|
|
|
static const WCHAR wszHeaders[] =
|
|
|
|
{'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
|
|
|
|
'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
|
|
|
|
'd','e','d','\r','\n',0};
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
CHECK_EXPECT(BeginningTransaction);
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
if(binding_test)
|
|
|
|
ok(!lstrcmpW(szURL, binding_urls[tested_protocol]), "szURL != http_url\n");
|
|
|
|
else
|
|
|
|
ok(!lstrcmpW(szURL, http_url), "szURL != http_url\n");
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
|
|
|
|
if(pszAdditionalHeaders)
|
2007-07-21 02:55:32 +02:00
|
|
|
{
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
|
2007-07-21 02:55:32 +02:00
|
|
|
if (http_post_test)
|
|
|
|
{
|
|
|
|
addl_headers = CoTaskMemAlloc(sizeof(wszHeaders));
|
|
|
|
if (!addl_headers)
|
|
|
|
{
|
2007-07-26 07:03:25 +02:00
|
|
|
http_post_test = FALSE;
|
2007-07-21 02:55:32 +02:00
|
|
|
skip("Out of memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
lstrcpyW(addl_headers, wszHeaders);
|
|
|
|
*pszAdditionalHeaders = addl_headers;
|
|
|
|
}
|
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
|
|
|
|
LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(OnResponse);
|
|
|
|
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
|
|
|
|
ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
|
|
|
|
ok(pszAdditionalRequestHeaders == NULL, "pszAdditionalHeaders != NULL\n");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
|
|
|
|
BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
|
|
|
static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
|
|
|
|
|
|
|
|
CHECK_EXPECT(GetRootSecurityId);
|
|
|
|
|
|
|
|
ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
|
|
|
|
ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
|
|
|
|
ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
|
|
|
|
|
|
|
|
if(pcbSecurityId) {
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
|
2005-12-31 13:32:40 +01:00
|
|
|
*pcbSecurityId = sizeof(sec_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pbSecurityId)
|
|
|
|
memcpy(pbSecurityId, sec_id, sizeof(sec_id));
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
|
|
|
|
HttpNegotiate_QueryInterface,
|
|
|
|
HttpNegotiate_AddRef,
|
|
|
|
HttpNegotiate_Release,
|
|
|
|
HttpNegotiate_BeginningTransaction,
|
|
|
|
HttpNegotiate_OnResponse,
|
|
|
|
HttpNegotiate_GetRootSecurityId
|
|
|
|
};
|
|
|
|
|
|
|
|
static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl };
|
|
|
|
|
|
|
|
static HRESULT QueryInterface(REFIID,void**);
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
return QueryInterface(riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IHttpNegotiate, guidService) || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
|
|
|
CHECK_EXPECT2(QueryService_HttpNegotiate);
|
|
|
|
return IHttpNegotiate2_QueryInterface(&http_negotiate, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
|
|
|
|
ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid\n");
|
|
|
|
CHECK_EXPECT(QueryService_InternetProtocol);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2009-04-07 12:22:14 +02:00
|
|
|
if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
|
|
|
|
ok(IsEqualGUID(&IID_IHttpSecurity, riid), "unexpected riid\n");
|
|
|
|
CHECK_EXPECT(QueryService_HttpSecurity);
|
|
|
|
return IHttpSecurity_QueryInterface(&http_security, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(0, "unexpected service %s\n", debugstr_guid(guidService));
|
2005-12-31 13:32:40 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
ServiceProvider_QueryInterface,
|
|
|
|
ServiceProvider_AddRef,
|
|
|
|
ServiceProvider_Release,
|
|
|
|
ServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
|
|
|
static IServiceProvider service_provider = { &ServiceProviderVtbl };
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
return QueryInterface(riid, ppv);
|
|
|
|
}
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
2007-07-27 07:44:33 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2009-03-30 00:41:54 +02:00
|
|
|
if(tested_protocol == FTP_TEST)
|
|
|
|
CHECK_EXPECT2(Switch);
|
|
|
|
else
|
|
|
|
CHECK_EXPECT(Switch);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(pProtocolData != NULL, "pProtocolData == NULL\n");
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
pdata = pProtocolData;
|
|
|
|
|
|
|
|
if(binding_test) {
|
|
|
|
SetEvent(event_complete);
|
|
|
|
WaitForSingleObject(event_complete2, INFINITE);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-27 07:44:33 +02:00
|
|
|
if (!state) {
|
2009-03-04 19:06:06 +01:00
|
|
|
if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST) {
|
|
|
|
if (http_is_first) {
|
|
|
|
CLEAR_CALLED(ReportProgress_FINDINGRESOURCE);
|
|
|
|
CLEAR_CALLED(ReportProgress_CONNECTING);
|
|
|
|
CLEAR_CALLED(ReportProgress_PROXYDETECTING);
|
|
|
|
} else todo_wine {
|
|
|
|
CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
|
|
|
|
/* IE7 does call this */
|
|
|
|
CLEAR_CALLED(ReportProgress_CONNECTING);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(tested_protocol == FTP_TEST)
|
|
|
|
todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
2009-04-07 12:22:14 +02:00
|
|
|
else if (tested_protocol != HTTPS_TEST)
|
2009-03-04 19:06:06 +01:00
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
|
|
|
|
SET_EXPECT(OnResponse);
|
|
|
|
if(tested_protocol == HTTPS_TEST)
|
|
|
|
SET_EXPECT(ReportProgress_ACCEPTRANGES);
|
|
|
|
SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
if(bindf & BINDF_NEEDFILE)
|
|
|
|
SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
2007-07-27 07:44:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_EXPECT(ReportData);
|
2009-03-04 19:06:06 +01:00
|
|
|
hres = IInternetProtocol_Continue(async_protocol, pProtocolData);
|
2007-07-27 07:44:33 +02:00
|
|
|
ok(hres == S_OK, "Continue failed: %08x\n", hres);
|
2009-03-04 19:06:06 +01:00
|
|
|
if(tested_protocol == FTP_TEST)
|
|
|
|
CLEAR_CALLED(ReportData);
|
2009-04-07 12:22:14 +02:00
|
|
|
else if (! security_problem)
|
2009-03-04 19:06:06 +01:00
|
|
|
CHECK_CALLED(ReportData);
|
2007-07-27 07:44:33 +02:00
|
|
|
|
|
|
|
if (!state) {
|
2009-04-07 12:22:14 +02:00
|
|
|
if (! security_problem)
|
|
|
|
{
|
|
|
|
state = 1;
|
|
|
|
if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
|
|
|
|
CHECK_CALLED(OnResponse);
|
|
|
|
if(tested_protocol == HTTPS_TEST)
|
|
|
|
CHECK_CALLED(ReportProgress_ACCEPTRANGES);
|
|
|
|
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
if(bindf & BINDF_NEEDFILE)
|
|
|
|
CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
security_problem = FALSE;
|
|
|
|
SET_EXPECT(ReportProgress_CONNECTING);
|
2009-03-04 19:06:06 +01:00
|
|
|
}
|
2007-07-27 07:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetEvent(event_complete);
|
2007-12-24 12:43:35 +01:00
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
return S_OK;
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
|
|
|
|
LPCWSTR szStatusText)
|
|
|
|
{
|
2007-01-23 19:36:38 +01:00
|
|
|
static const WCHAR null_guid[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
|
|
|
|
'0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
|
2007-07-21 02:55:32 +02:00
|
|
|
static const WCHAR text_plain[] = {'t','e','x','t','/','p','l','a','i','n',0};
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
switch(ulStatusCode) {
|
2005-12-31 13:32:40 +01:00
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
|
|
|
CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
if(szStatusText) {
|
|
|
|
if(tested_protocol == BIND_TEST)
|
|
|
|
ok(szStatusText == expect_wsz, "unexpected szStatusText\n");
|
2007-07-21 02:55:32 +02:00
|
|
|
else if (http_post_test)
|
|
|
|
ok(lstrlenW(text_plain) <= lstrlenW(szStatusText) &&
|
|
|
|
!memcmp(szStatusText, text_plain, lstrlenW(text_plain)*sizeof(WCHAR)),
|
|
|
|
"szStatusText != text/plain\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
else
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(lstrlenW(text_htmlW) <= lstrlenW(szStatusText) &&
|
|
|
|
!memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
|
2007-07-08 23:52:10 +02:00
|
|
|
"szStatusText != text/html\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_DIRECTBIND:
|
|
|
|
CHECK_EXPECT2(ReportProgress_DIRECTBIND);
|
|
|
|
ok(szStatusText == NULL, "szStatusText != NULL\n");
|
|
|
|
break;
|
2007-07-19 03:00:20 +02:00
|
|
|
case BINDSTATUS_RAWMIMETYPE:
|
|
|
|
CHECK_EXPECT2(ReportProgress_RAWMIMETYPE);
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText)
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(lstrlenW(szStatusText) < lstrlenW(text_htmlW) ||
|
|
|
|
!memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
|
2007-07-19 03:00:20 +02:00
|
|
|
"szStatusText != text/html\n");
|
|
|
|
break;
|
2005-12-31 13:32:40 +01:00
|
|
|
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
|
|
|
|
CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
if(szStatusText) {
|
2007-12-24 12:43:35 +01:00
|
|
|
if(binding_test)
|
2008-06-01 04:10:54 +02:00
|
|
|
ok(!lstrcmpW(szStatusText, expect_wsz), "unexpected szStatusText\n");
|
2008-01-31 18:18:49 +01:00
|
|
|
else if(tested_protocol == FILE_TEST)
|
|
|
|
ok(!lstrcmpW(szStatusText, file_name), "szStatusText = \"%s\"\n", debugstr_w(szStatusText));
|
2007-01-23 19:36:38 +01:00
|
|
|
else
|
2008-01-31 18:18:49 +01:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_FINDINGRESOURCE:
|
2009-04-07 12:22:14 +02:00
|
|
|
CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_CONNECTING:
|
2009-04-07 12:22:14 +02:00
|
|
|
CHECK_EXPECT2(ReportProgress_CONNECTING);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_SENDINGREQUEST:
|
2009-03-04 19:06:06 +01:00
|
|
|
CHECK_EXPECT2(ReportProgress_SENDINGREQUEST);
|
2005-12-31 13:32:40 +01:00
|
|
|
if(tested_protocol == FILE_TEST) {
|
2005-10-29 12:28:47 +02:00
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText)
|
|
|
|
ok(!*szStatusText, "wrong szStatusText\n");
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
|
|
|
|
CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
if(szStatusText)
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(!lstrcmpW(szStatusText, text_htmlW), "szStatusText != text/html\n");
|
2005-12-31 13:32:40 +01:00
|
|
|
break;
|
2007-01-23 19:36:38 +01:00
|
|
|
case BINDSTATUS_PROTOCOLCLASSID:
|
|
|
|
CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID);
|
|
|
|
ok(szStatusText != NULL, "szStatusText == NULL\n");
|
|
|
|
ok(!lstrcmpW(szStatusText, null_guid), "unexpected szStatusText\n");
|
|
|
|
break;
|
2007-12-24 12:43:35 +01:00
|
|
|
case BINDSTATUS_COOKIE_SENT:
|
|
|
|
CHECK_EXPECT(ReportProgress_COOKIE_SENT);
|
|
|
|
ok(szStatusText == NULL, "szStatusText != NULL\n");
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_REDIRECTING:
|
|
|
|
CHECK_EXPECT(ReportProgress_REDIRECTING);
|
2009-01-12 18:20:06 +01:00
|
|
|
ok(szStatusText == NULL, "szStatusText = %s\n", debugstr_w(szStatusText));
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_ENCODING:
|
|
|
|
CHECK_EXPECT(ReportProgress_ENCODING);
|
|
|
|
ok(!strcmp_wa(szStatusText, "gzip"), "szStatusText = %s\n", debugstr_w(szStatusText));
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_ACCEPTRANGES:
|
|
|
|
CHECK_EXPECT(ReportProgress_ACCEPTRANGES);
|
|
|
|
ok(!szStatusText, "szStatusText = %s\n", debugstr_w(szStatusText));
|
2007-12-24 12:43:35 +01:00
|
|
|
break;
|
2009-01-20 02:56:46 +01:00
|
|
|
case BINDSTATUS_PROXYDETECTING:
|
|
|
|
CHECK_EXPECT(ReportProgress_PROXYDETECTING);
|
|
|
|
SET_EXPECT(ReportProgress_CONNECTING);
|
|
|
|
ok(!szStatusText, "szStatusText = %s\n", debugstr_w(szStatusText));
|
|
|
|
break;
|
2005-12-31 13:32:40 +01:00
|
|
|
default:
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(0, "Unexpected status %d\n", ulStatusCode);
|
2005-09-06 11:27:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF,
|
|
|
|
ULONG ulProgress, ULONG ulProgressMax)
|
|
|
|
{
|
2005-12-31 13:32:40 +01:00
|
|
|
if(tested_protocol == FILE_TEST) {
|
|
|
|
CHECK_EXPECT2(ReportData);
|
|
|
|
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(ulProgress == ulProgressMax, "ulProgress (%d) != ulProgressMax (%d)\n",
|
2005-12-31 13:32:40 +01:00
|
|
|
ulProgress, ulProgressMax);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax);
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION),
|
2006-10-07 15:30:28 +02:00
|
|
|
"grcfBSCF = %08x\n", grfBSCF);
|
2009-03-04 19:06:06 +01:00
|
|
|
}else if(!binding_test && (tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST)) {
|
2009-01-20 02:56:46 +01:00
|
|
|
if(!(grfBSCF & BSCF_LASTDATANOTIFICATION) || (grfBSCF & BSCF_DATAFULLYAVAILABLE))
|
2005-12-31 13:32:40 +01:00
|
|
|
CHECK_EXPECT(ReportData);
|
2007-07-21 02:56:12 +02:00
|
|
|
else if (http_post_test)
|
2007-07-21 02:55:32 +02:00
|
|
|
ok(ulProgress == 13, "Read %u bytes instead of 13\n", ulProgress);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
ok(ulProgress, "ulProgress == 0\n");
|
|
|
|
|
|
|
|
if(first_data_notif) {
|
2009-01-20 02:56:46 +01:00
|
|
|
ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION
|
|
|
|
|| grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE),
|
|
|
|
"grcfBSCF = %08x\n", grfBSCF);
|
2005-12-31 13:32:40 +01:00
|
|
|
first_data_notif = FALSE;
|
|
|
|
} else {
|
|
|
|
ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION
|
2009-01-20 02:56:46 +01:00
|
|
|
|| grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION)
|
|
|
|
|| broken(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION)),
|
2006-10-07 15:30:28 +02:00
|
|
|
"grcfBSCF = %08x\n", grfBSCF);
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
2007-07-19 03:00:20 +02:00
|
|
|
|
2007-07-27 07:44:33 +02:00
|
|
|
if(!(bindf & BINDF_FROMURLMON) &&
|
|
|
|
!(grfBSCF & BSCF_LASTDATANOTIFICATION)) {
|
|
|
|
if(!state) {
|
|
|
|
state = 1;
|
|
|
|
if(http_is_first) {
|
|
|
|
CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
|
|
|
|
CHECK_CALLED(ReportProgress_CONNECTING);
|
|
|
|
} else todo_wine {
|
|
|
|
CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
|
|
|
|
CHECK_NOT_CALLED(ReportProgress_CONNECTING);
|
|
|
|
}
|
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
CHECK_CALLED(OnResponse);
|
|
|
|
CHECK_CALLED(ReportProgress_RAWMIMETYPE);
|
|
|
|
}
|
2007-07-27 07:39:17 +02:00
|
|
|
SetEvent(event_complete);
|
2007-07-27 07:44:33 +02:00
|
|
|
}
|
2007-12-24 12:41:57 +01:00
|
|
|
}else {
|
2007-12-28 14:54:48 +01:00
|
|
|
BYTE buf[1000];
|
|
|
|
ULONG read;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2007-12-24 12:41:57 +01:00
|
|
|
CHECK_EXPECT(ReportData);
|
2007-12-28 14:54:48 +01:00
|
|
|
|
|
|
|
if(tested_protocol == BIND_TEST)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
do {
|
|
|
|
SET_EXPECT(Read);
|
|
|
|
hres = IInternetProtocol_Read(binding_protocol, expect_pv=buf, sizeof(buf), &read);
|
|
|
|
CHECK_CALLED(Read);
|
|
|
|
}while(hres == S_OK);
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
2007-12-24 12:41:57 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult,
|
|
|
|
DWORD dwError, LPCWSTR szResult)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(ReportResult);
|
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
if(tested_protocol == FTP_TEST)
|
|
|
|
ok(hrResult == E_PENDING || hrResult == S_OK, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult);
|
|
|
|
else
|
|
|
|
ok(hrResult == expect_hrResult, "hrResult = %08x, expected: %08x\n",
|
|
|
|
hrResult, expect_hrResult);
|
|
|
|
if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST)
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(dwError == ERROR_SUCCESS, "dwError = %d, expected ERROR_SUCCESS\n", dwError);
|
2005-09-06 11:27:04 +02:00
|
|
|
else
|
|
|
|
ok(dwError != ERROR_SUCCESS, "dwError == ERROR_SUCCESS\n");
|
|
|
|
ok(!szResult, "szResult != NULL\n");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
|
|
|
|
ProtocolSink_QueryInterface,
|
|
|
|
ProtocolSink_AddRef,
|
|
|
|
ProtocolSink_Release,
|
|
|
|
ProtocolSink_Switch,
|
|
|
|
ProtocolSink_ReportProgress,
|
|
|
|
ProtocolSink_ReportData,
|
|
|
|
ProtocolSink_ReportResult
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetProtocolSink protocol_sink = { &protocol_sink_vtbl };
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
static HRESULT QueryInterface(REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid))
|
|
|
|
*ppv = &protocol_sink;
|
|
|
|
if(IsEqualGUID(&IID_IServiceProvider, riid))
|
|
|
|
*ppv = &service_provider;
|
|
|
|
|
|
|
|
if(*ppv)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2005-12-31 13:32:40 +01:00
|
|
|
DWORD cbSize;
|
|
|
|
|
2007-07-21 02:55:32 +02:00
|
|
|
static const CHAR szPostData[] = "mode=Test";
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_EXPECT(GetBindInfo);
|
|
|
|
|
|
|
|
ok(grfBINDF != NULL, "grfBINDF == NULL\n");
|
|
|
|
ok(pbindinfo != NULL, "pbindinfo == NULL\n");
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
|
2005-12-19 09:57:25 +01:00
|
|
|
|
|
|
|
*grfBINDF = bindf;
|
2007-12-24 12:43:35 +01:00
|
|
|
if(binding_test)
|
|
|
|
*grfBINDF |= BINDF_FROMURLMON;
|
2005-12-31 13:32:40 +01:00
|
|
|
cbSize = pbindinfo->cbSize;
|
|
|
|
memset(pbindinfo, 0, cbSize);
|
|
|
|
pbindinfo->cbSize = cbSize;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2007-07-21 02:55:32 +02:00
|
|
|
if (http_post_test)
|
|
|
|
{
|
|
|
|
/* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly
|
|
|
|
* with urlmon on native (Win98 and WinXP) */
|
2007-08-08 10:48:45 +02:00
|
|
|
U(pbindinfo->stgmedData).hGlobal = GlobalAlloc(GPTR, sizeof(szPostData));
|
|
|
|
if (!U(pbindinfo->stgmedData).hGlobal)
|
2007-07-21 02:55:32 +02:00
|
|
|
{
|
2007-07-26 07:03:25 +02:00
|
|
|
http_post_test = FALSE;
|
2007-07-21 02:55:32 +02:00
|
|
|
skip("Out of memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2007-08-08 10:48:45 +02:00
|
|
|
lstrcpy((LPSTR)U(pbindinfo->stgmedData).hGlobal, szPostData);
|
2007-07-21 02:55:32 +02:00
|
|
|
pbindinfo->cbstgmedData = sizeof(szPostData)-1;
|
2007-07-26 07:03:25 +02:00
|
|
|
pbindinfo->dwBindVerb = BINDVERB_POST;
|
|
|
|
pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
|
2007-07-21 02:55:32 +02:00
|
|
|
}
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType,
|
|
|
|
LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
|
|
|
|
{
|
2005-12-31 13:32:40 +01:00
|
|
|
ok(ppwzStr != NULL, "ppwzStr == NULL\n");
|
|
|
|
ok(pcElFetched != NULL, "pcElFetched == NULL\n");
|
|
|
|
|
|
|
|
switch(ulStringType) {
|
|
|
|
case BINDSTRING_ACCEPT_MIMES:
|
|
|
|
CHECK_EXPECT(GetBindString_ACCEPT_MIMES);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(cEl == 256, "cEl=%d, expected 256\n", cEl);
|
2005-12-31 13:32:40 +01:00
|
|
|
if(pcElFetched) {
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(*pcElFetched == 256, "*pcElFetched=%d, expected 256\n", *pcElFetched);
|
2005-12-31 13:32:40 +01:00
|
|
|
*pcElFetched = 1;
|
|
|
|
}
|
|
|
|
if(ppwzStr) {
|
2007-12-24 12:43:35 +01:00
|
|
|
*ppwzStr = CoTaskMemAlloc(sizeof(acc_mimeW));
|
|
|
|
memcpy(*ppwzStr, acc_mimeW, sizeof(acc_mimeW));
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
case BINDSTRING_USER_AGENT:
|
|
|
|
CHECK_EXPECT(GetBindString_USER_AGENT);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
|
2005-12-31 13:32:40 +01:00
|
|
|
if(pcElFetched) {
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
|
2005-12-31 13:32:40 +01:00
|
|
|
*pcElFetched = 1;
|
|
|
|
}
|
|
|
|
if(ppwzStr) {
|
2007-12-24 12:43:35 +01:00
|
|
|
*ppwzStr = CoTaskMemAlloc(sizeof(user_agentW));
|
|
|
|
memcpy(*ppwzStr, user_agentW, sizeof(user_agentW));
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
2007-07-21 02:55:32 +02:00
|
|
|
case BINDSTRING_POST_COOKIE:
|
|
|
|
CHECK_EXPECT(GetBindString_POST_COOKIE);
|
|
|
|
ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
|
|
|
|
if(pcElFetched)
|
|
|
|
ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
|
|
|
|
return S_OK;
|
2005-12-31 13:32:40 +01:00
|
|
|
default:
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
}
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IInternetBindInfoVtbl bind_info_vtbl = {
|
|
|
|
BindInfo_QueryInterface,
|
|
|
|
BindInfo_AddRef,
|
|
|
|
BindInfo_Release,
|
|
|
|
BindInfo_GetBindInfo,
|
|
|
|
BindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetBindInfo bind_info = { &bind_info_vtbl };
|
|
|
|
|
2007-01-23 23:33:38 +01:00
|
|
|
static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(SetPriority);
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(nPriority == ex_priority, "nPriority=%d\n", nPriority);
|
2007-01-23 23:33:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const IInternetPriorityVtbl InternetPriorityVtbl = {
|
|
|
|
InternetPriority_QueryInterface,
|
|
|
|
InternetPriority_AddRef,
|
|
|
|
InternetPriority_Release,
|
|
|
|
InternetPriority_SetPriority,
|
|
|
|
InternetPriority_GetPriority
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-14 12:08:26 +01:00
|
|
|
if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
|
|
|
|
trace("IID_IInternetProtocolEx not supported\n");
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2007-01-23 23:33:38 +01:00
|
|
|
if(IsEqualGUID(&IID_IInternetPriority, riid)) {
|
|
|
|
*ppv = &InternetPriority;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-01-23 19:36:38 +01:00
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(0, "unexpected riid %s\n", debugstr_guid(riid));
|
2007-01-23 19:36:38 +01:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
static DWORD WINAPI thread_proc(PVOID arg)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
memset(&protocoldata, -1, sizeof(protocoldata));
|
|
|
|
|
|
|
|
prot_state = 0;
|
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_FINDINGRESOURCE);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(binding_sink,
|
|
|
|
BINDSTATUS_FINDINGRESOURCE, hostW);
|
|
|
|
CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
|
|
|
|
ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_CONNECTING);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(binding_sink,
|
|
|
|
BINDSTATUS_CONNECTING, winehq_ipW);
|
|
|
|
CHECK_CALLED(ReportProgress_CONNECTING);
|
|
|
|
ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(binding_sink,
|
|
|
|
BINDSTATUS_SENDINGREQUEST, NULL);
|
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
|
|
|
|
|
|
|
|
prot_state = 1;
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
|
|
|
|
CHECK_CALLED(Switch);
|
|
|
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
|
|
|
|
|
|
|
prot_state = 2;
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
|
|
|
|
CHECK_CALLED(Switch);
|
|
|
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
|
|
|
|
|
|
|
prot_state = 2;
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
|
|
|
|
CHECK_CALLED(Switch);
|
|
|
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
|
|
|
|
|
|
|
prot_state = 3;
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
|
|
|
|
CHECK_CALLED(Switch);
|
|
|
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
SetEvent(event_complete);
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
2009-04-01 03:42:37 +02:00
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
2007-01-23 19:36:38 +01:00
|
|
|
{
|
|
|
|
BINDINFO bindinfo, exp_bindinfo;
|
|
|
|
DWORD cbindf = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
CHECK_EXPECT(Start);
|
|
|
|
|
|
|
|
ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
|
|
|
|
ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(pOIProtSink != &protocol_sink, "unexpected pOIProtSink\n");
|
|
|
|
ok(pOIBindInfo != &bind_info, "unexpected pOIBindInfo\n");
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(!grfPI, "grfPI = %x\n", grfPI);
|
2009-04-01 03:42:37 +02:00
|
|
|
ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
|
2007-01-23 19:36:38 +01:00
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(bindinfo);
|
|
|
|
memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
|
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
|
|
|
|
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetBindInfo);
|
|
|
|
ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
|
|
|
|
cbindf, (bindf|BINDF_FROMURLMON));
|
|
|
|
ok(!memcmp(&exp_bindinfo, &bindinfo, sizeof(bindinfo)), "unexpected bindinfo\n");
|
2007-12-28 14:54:48 +01:00
|
|
|
ReleaseBindInfo(&bindinfo);
|
2007-01-23 19:36:38 +01:00
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
2007-12-28 14:54:48 +01:00
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, emptyW);
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(hres == S_OK, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
|
2009-01-12 18:20:06 +01:00
|
|
|
if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
|
2007-12-24 12:43:35 +01:00
|
|
|
IServiceProvider *service_provider;
|
|
|
|
IHttpNegotiate *http_negotiate;
|
|
|
|
IHttpNegotiate2 *http_negotiate2;
|
|
|
|
LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
|
|
|
|
LPWSTR additional_headers = NULL;
|
|
|
|
BYTE sec_id[100];
|
|
|
|
DWORD fetched = 0, size = 100;
|
2008-09-08 08:10:16 +02:00
|
|
|
DWORD tid;
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindString_USER_AGENT);
|
|
|
|
hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
|
|
|
|
&ua, 1, &fetched);
|
|
|
|
CHECK_CALLED(GetBindString_USER_AGENT);
|
|
|
|
ok(hres == S_OK, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
|
|
|
|
ok(fetched == 1, "fetched = %d, expected 254\n", fetched);
|
|
|
|
ok(ua != NULL, "ua = %p\n", ua);
|
|
|
|
ok(!lstrcmpW(ua, user_agentW), "unexpected user agent %s\n", debugstr_w(ua));
|
|
|
|
CoTaskMemFree(ua);
|
|
|
|
|
|
|
|
fetched = 256;
|
|
|
|
SET_EXPECT(GetBindString_ACCEPT_MIMES);
|
|
|
|
hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
|
|
|
|
accept_mimes, 256, &fetched);
|
|
|
|
CHECK_CALLED(GetBindString_ACCEPT_MIMES);
|
|
|
|
|
|
|
|
ok(hres == S_OK,
|
|
|
|
"GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
|
|
|
|
ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
|
|
|
|
ok(!lstrcmpW(acc_mimeW, accept_mimes[0]), "unexpected mimes %s\n", debugstr_w(accept_mimes[0]));
|
|
|
|
|
|
|
|
hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
|
|
|
|
(void**)&service_provider);
|
|
|
|
ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(QueryService_HttpNegotiate);
|
|
|
|
hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
|
|
|
|
&IID_IHttpNegotiate, (void**)&http_negotiate);
|
|
|
|
CHECK_CALLED(QueryService_HttpNegotiate);
|
|
|
|
ok(hres == S_OK, "QueryService failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(BeginningTransaction);
|
|
|
|
hres = IHttpNegotiate_BeginningTransaction(http_negotiate, binding_urls[tested_protocol],
|
|
|
|
NULL, 0, &additional_headers);
|
|
|
|
CHECK_CALLED(BeginningTransaction);
|
|
|
|
IHttpNegotiate_Release(http_negotiate);
|
|
|
|
ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
|
|
|
|
ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
|
|
|
|
|
|
|
|
SET_EXPECT(QueryService_HttpNegotiate);
|
|
|
|
hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
|
|
|
|
&IID_IHttpNegotiate2, (void**)&http_negotiate2);
|
|
|
|
CHECK_CALLED(QueryService_HttpNegotiate);
|
|
|
|
ok(hres == S_OK, "QueryService failed: %08x\n", hres);
|
|
|
|
|
|
|
|
size = 512;
|
|
|
|
SET_EXPECT(GetRootSecurityId);
|
|
|
|
hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
|
|
|
|
CHECK_CALLED(GetRootSecurityId);
|
|
|
|
IHttpNegotiate2_Release(http_negotiate2);
|
|
|
|
ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
|
|
|
|
ok(size == 13, "size=%d\n", size);
|
|
|
|
|
|
|
|
IServiceProvider_Release(service_provider);
|
|
|
|
|
2008-09-08 08:10:16 +02:00
|
|
|
CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
|
2007-12-28 14:54:48 +01:00
|
|
|
BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
|
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
2007-12-24 12:43:35 +01:00
|
|
|
hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
|
2007-12-28 14:54:48 +01:00
|
|
|
expect_wsz = text_htmlW);
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(hres == S_OK,
|
|
|
|
"ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
|
2007-12-24 12:41:57 +01:00
|
|
|
SET_EXPECT(ReportData);
|
2007-01-23 19:36:38 +01:00
|
|
|
hres = IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
|
|
|
|
ok(hres == S_OK, "ReportData failed: %08x\n", hres);
|
2007-12-24 12:41:57 +01:00
|
|
|
CHECK_CALLED(ReportData);
|
2007-01-23 19:36:38 +01:00
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
if(tested_protocol == BIND_TEST) {
|
|
|
|
hres = IInternetProtocol_Terminate(binding_protocol, 0);
|
|
|
|
ok(hres == E_FAIL, "Termiante failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
|
|
|
ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(ReportResult);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
|
|
|
|
PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
2007-12-24 12:43:35 +01:00
|
|
|
DWORD bscf = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
CHECK_EXPECT(Continue);
|
|
|
|
|
|
|
|
ok(pProtocolData != NULL, "pProtocolData == NULL\n");
|
2007-12-28 14:54:48 +01:00
|
|
|
if(!pProtocolData || tested_protocol == BIND_TEST)
|
2007-12-24 12:43:35 +01:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
switch(prot_state) {
|
|
|
|
case 1: {
|
|
|
|
IServiceProvider *service_provider;
|
|
|
|
IHttpNegotiate *http_negotiate;
|
|
|
|
static WCHAR header[] = {'?',0};
|
|
|
|
|
|
|
|
hres = IInternetProtocolSink_QueryInterface(binding_sink, &IID_IServiceProvider,
|
|
|
|
(void**)&service_provider);
|
|
|
|
ok(hres == S_OK, "Could not get IServiceProvicder\n");
|
|
|
|
|
|
|
|
SET_EXPECT(QueryService_HttpNegotiate);
|
|
|
|
hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
|
|
|
|
&IID_IHttpNegotiate, (void**)&http_negotiate);
|
2007-12-28 14:54:48 +01:00
|
|
|
IServiceProvider_Release(service_provider);
|
2007-12-24 12:43:35 +01:00
|
|
|
CHECK_CALLED(QueryService_HttpNegotiate);
|
|
|
|
ok(hres == S_OK, "Could not get IHttpNegotiate\n");
|
|
|
|
|
|
|
|
SET_EXPECT(OnResponse);
|
|
|
|
hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
|
2007-12-28 14:54:48 +01:00
|
|
|
IHttpNegotiate_Release(http_negotiate);
|
2007-12-24 12:43:35 +01:00
|
|
|
CHECK_CALLED(OnResponse);
|
|
|
|
IHttpNegotiate_Release(http_negotiate);
|
|
|
|
ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
|
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(binding_sink,
|
|
|
|
BINDSTATUS_MIMETYPEAVAILABLE, text_htmlW);
|
|
|
|
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
ok(hres == S_OK,
|
|
|
|
"ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
bscf |= BSCF_FIRSTDATANOTIFICATION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_EXPECT(ReportData);
|
|
|
|
hres = IInternetProtocolSink_ReportData(binding_sink, bscf, 100, 400);
|
|
|
|
CHECK_CALLED(ReportData);
|
|
|
|
ok(hres == S_OK, "ReportData failed: %08x\n", hres);
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
if(prot_state == 3)
|
|
|
|
prot_state = 4;
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
return S_OK;
|
2007-01-23 19:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(Terminate);
|
|
|
|
ok(!dwOptions, "dwOptions=%d\n", dwOptions);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
|
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2007-12-28 14:54:48 +01:00
|
|
|
static BOOL b = TRUE;
|
2007-01-23 19:36:38 +01:00
|
|
|
|
|
|
|
CHECK_EXPECT(Read);
|
|
|
|
|
|
|
|
ok(pv == expect_pv, "pv != expect_pv\n");
|
|
|
|
ok(cb == 1000, "cb=%d\n", cb);
|
|
|
|
ok(pcbRead != NULL, "pcbRead == NULL\n");
|
|
|
|
ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
if(prot_state == 3) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
|
|
|
|
CHECK_CALLED(ReportResult);
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
return S_FALSE;
|
2007-12-28 14:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if((b = !b))
|
2009-01-12 18:20:06 +01:00
|
|
|
return tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST ? E_PENDING : S_FALSE;
|
2007-01-23 19:36:38 +01:00
|
|
|
|
|
|
|
memset(pv, 'x', 100);
|
2007-12-28 14:54:48 +01:00
|
|
|
prot_read += *pcbRead = 100;
|
2007-01-23 19:36:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
|
|
|
|
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
2007-12-24 12:43:35 +01:00
|
|
|
CHECK_EXPECT(LockRequest);
|
|
|
|
ok(dwOptions == 0, "dwOptions=%x\n", dwOptions);
|
2007-01-23 19:36:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
|
|
|
|
{
|
2007-12-24 12:43:35 +01:00
|
|
|
CHECK_EXPECT(UnlockRequest);
|
2007-01-23 19:36:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolVtbl ProtocolVtbl = {
|
|
|
|
Protocol_QueryInterface,
|
|
|
|
Protocol_AddRef,
|
|
|
|
Protocol_Release,
|
|
|
|
Protocol_Start,
|
|
|
|
Protocol_Continue,
|
|
|
|
Protocol_Abort,
|
|
|
|
Protocol_Terminate,
|
|
|
|
Protocol_Suspend,
|
|
|
|
Protocol_Resume,
|
|
|
|
Protocol_Read,
|
|
|
|
Protocol_Seek,
|
|
|
|
Protocol_LockRequest,
|
|
|
|
Protocol_UnlockRequest
|
|
|
|
};
|
|
|
|
|
|
|
|
static IInternetProtocol Protocol = { &ProtocolVtbl };
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
CHECK_EXPECT(CreateInstance);
|
|
|
|
|
|
|
|
ok(pOuter == (IUnknown*)prot_bind_info, "pOuter != protocol_unk\n");
|
2007-12-24 12:43:35 +01:00
|
|
|
ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(ppv != NULL, "ppv == NULL\n");
|
|
|
|
|
|
|
|
*ppv = &Protocol;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ClassFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
ClassFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static IClassFactory ClassFactory = { &ClassFactoryVtbl };
|
|
|
|
|
2005-11-09 11:28:26 +01:00
|
|
|
static void test_priority(IInternetProtocol *protocol)
|
|
|
|
{
|
|
|
|
IInternetPriority *priority;
|
|
|
|
LONG pr;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority,
|
|
|
|
(void**)&priority);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
|
2005-11-09 11:28:26 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IInternetPriority_GetPriority(priority, &pr);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
|
|
|
|
ok(pr == 0, "pr=%d, expected 0\n", pr);
|
2005-11-09 11:28:26 +01:00
|
|
|
|
|
|
|
hres = IInternetPriority_SetPriority(priority, 1);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
|
2005-11-09 11:28:26 +01:00
|
|
|
|
|
|
|
hres = IInternetPriority_GetPriority(priority, &pr);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
|
|
|
|
ok(pr == 1, "pr=%d, expected 1\n", pr);
|
2005-11-09 11:28:26 +01:00
|
|
|
|
|
|
|
IInternetPriority_Release(priority);
|
|
|
|
}
|
|
|
|
|
2008-09-28 23:00:59 +02:00
|
|
|
static BOOL file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_first)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
SET_EXPECT(ReportProgress_DIRECTBIND);
|
2005-09-06 11:27:04 +02:00
|
|
|
if(is_first) {
|
2005-10-29 12:28:47 +02:00
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(bindf & BINDF_FROMURLMON)
|
|
|
|
SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
|
|
|
|
else
|
|
|
|
SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
SET_EXPECT(ReportData);
|
2005-12-19 09:52:30 +01:00
|
|
|
if(is_first)
|
|
|
|
SET_EXPECT(ReportResult);
|
2005-12-19 09:57:25 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
expect_hrResult = S_OK;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
|
2008-09-28 23:00:59 +02:00
|
|
|
if(hres == INET_E_RESOURCE_NOT_FOUND) {
|
|
|
|
win_skip("Start failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "Start failed: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
CHECK_CALLED(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
CHECK_CALLED(ReportProgress_DIRECTBIND);
|
2005-09-06 11:27:04 +02:00
|
|
|
if(is_first) {
|
2005-10-29 12:28:47 +02:00
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(bindf & BINDF_FROMURLMON)
|
|
|
|
CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
|
|
|
|
else
|
|
|
|
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
CHECK_CALLED(ReportData);
|
2005-12-19 09:52:30 +01:00
|
|
|
if(is_first)
|
|
|
|
CHECK_CALLED(ReportResult);
|
2008-09-28 23:00:59 +02:00
|
|
|
|
|
|
|
return TRUE;
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_file_protocol_url(LPCWSTR url)
|
|
|
|
{
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
IUnknown *unk;
|
|
|
|
IClassFactory *factory;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CoGetClassObject(&CLSID_FileProtocol, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IUnknown, (void**)&unk);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
|
2008-10-08 01:34:35 +02:00
|
|
|
if(FAILED(hres))
|
2005-09-06 11:27:04 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
|
|
|
|
ok(hres == E_NOINTERFACE,
|
2006-10-07 15:30:28 +02:00
|
|
|
"Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
|
|
|
|
ok(hres == S_OK, "Could not get IClassFactory interface\n");
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetProtocol *protocol;
|
|
|
|
BYTE buf[512];
|
|
|
|
ULONG cb;
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
2008-09-28 23:00:59 +02:00
|
|
|
if(file_protocol_start(protocol, url, TRUE)) {
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
|
|
|
|
ok(hres == S_OK, "Read failed: %08x\n", hres);
|
|
|
|
ok(cb == 2, "cb=%u expected 2\n", cb);
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
|
|
|
|
ok(cb == 0, "cb=%u expected 0\n", cb);
|
|
|
|
hres = IInternetProtocol_UnlockRequest(protocol);
|
|
|
|
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(file_protocol_start(protocol, url, FALSE)) {
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_LockRequest(protocol, 0);
|
|
|
|
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_UnlockRequest(protocol);
|
|
|
|
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
|
|
|
|
}
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
2008-09-28 23:00:59 +02:00
|
|
|
if(file_protocol_start(protocol, url, TRUE)) {
|
|
|
|
hres = IInternetProtocol_LockRequest(protocol, 0);
|
|
|
|
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
|
|
|
|
ok(hres == S_OK, "Read failed: %08x\n\n", hres);
|
|
|
|
hres = IInternetProtocol_UnlockRequest(protocol);
|
|
|
|
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
|
|
|
|
ok(hres == S_OK, "Read failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
}
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
2008-09-28 23:00:59 +02:00
|
|
|
if(file_protocol_start(protocol, url, TRUE)) {
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
|
|
|
|
ok(hres == S_OK, "Read failed: %08x\n", hres);
|
|
|
|
ok(cb == 2, "cb=%u expected 2\n", cb);
|
|
|
|
}
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
}
|
|
|
|
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
|
2005-12-19 09:57:25 +01:00
|
|
|
static void test_file_protocol_fail(void)
|
|
|
|
{
|
2005-09-06 11:27:04 +02:00
|
|
|
IInternetProtocol *protocol;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR index_url2[] =
|
|
|
|
{'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IInternetProtocol, (void**)&protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
expect_hrResult = MK_E_SYNTAX;
|
|
|
|
hres = IInternetProtocol_Start(protocol, wszIndexHtml, &protocol_sink, &bind_info, 0, 0);
|
2008-06-24 23:53:51 +02:00
|
|
|
ok(hres == MK_E_SYNTAX ||
|
|
|
|
hres == E_INVALIDARG,
|
|
|
|
"Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres);
|
|
|
|
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
SET_EXPECT(ReportProgress_DIRECTBIND);
|
2005-10-29 12:28:47 +02:00
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
|
|
|
|
hres = IInternetProtocol_Start(protocol, index_url, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == INET_E_RESOURCE_NOT_FOUND,
|
2006-10-07 15:30:28 +02:00
|
|
|
"Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_CALLED(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
CHECK_CALLED(ReportProgress_DIRECTBIND);
|
2005-10-29 12:28:47 +02:00
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_CALLED(ReportResult);
|
|
|
|
|
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IInternetProtocol, (void**)&protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
SET_EXPECT(ReportProgress_DIRECTBIND);
|
2005-10-29 12:28:47 +02:00
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
|
2005-12-19 09:57:25 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
hres = IInternetProtocol_Start(protocol, index_url2, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == INET_E_RESOURCE_NOT_FOUND,
|
2006-10-07 15:30:28 +02:00
|
|
|
"Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres);
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_CALLED(GetBindInfo);
|
2005-12-19 09:57:25 +01:00
|
|
|
if(!(bindf & BINDF_FROMURLMON))
|
|
|
|
CHECK_CALLED(ReportProgress_DIRECTBIND);
|
2005-10-29 12:28:47 +02:00
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
CHECK_CALLED(ReportResult);
|
|
|
|
|
2008-05-10 14:20:53 +02:00
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
|
2008-06-24 23:53:51 +02:00
|
|
|
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
|
2008-05-10 14:20:53 +02:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
hres = IInternetProtocol_Start(protocol, emptyW, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
|
2008-06-24 23:53:51 +02:00
|
|
|
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
|
2008-05-10 14:20:53 +02:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
}
|
|
|
|
|
2005-12-19 09:57:25 +01:00
|
|
|
static void test_file_protocol(void) {
|
2008-05-10 14:20:43 +02:00
|
|
|
WCHAR buf[INTERNET_MAX_URL_LENGTH], file_name_buf[MAX_PATH];
|
2005-12-19 09:57:25 +01:00
|
|
|
DWORD size;
|
|
|
|
ULONG len;
|
|
|
|
HANDLE file;
|
|
|
|
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',':',0};
|
2005-12-26 12:59:31 +01:00
|
|
|
static const WCHAR wszFile2[] = {'f','i','l','e',':','/','/',0};
|
|
|
|
static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0};
|
2005-12-19 09:57:25 +01:00
|
|
|
static const char html_doc[] = "<HTML></HTML>";
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
trace("Testing file protocol...\n");
|
2005-12-31 13:32:40 +01:00
|
|
|
tested_protocol = FILE_TEST;
|
|
|
|
|
2008-11-11 10:09:39 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2005-12-19 09:57:25 +01:00
|
|
|
file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
2008-11-11 10:09:39 +01:00
|
|
|
if(!file && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("Detected Win9x or WinMe\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-12-19 09:57:25 +01:00
|
|
|
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
return;
|
|
|
|
WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
file_name = wszIndexHtml;
|
|
|
|
bindf = 0;
|
|
|
|
test_file_protocol_url(index_url);
|
|
|
|
bindf = BINDF_FROMURLMON;
|
|
|
|
test_file_protocol_url(index_url);
|
2008-01-31 18:18:49 +01:00
|
|
|
bindf = BINDF_FROMURLMON | BINDF_NEEDFILE;
|
|
|
|
test_file_protocol_url(index_url);
|
2005-12-19 09:57:25 +01:00
|
|
|
|
|
|
|
memcpy(buf, wszFile, sizeof(wszFile));
|
|
|
|
len = sizeof(wszFile)/sizeof(WCHAR)-1;
|
|
|
|
len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
|
|
|
|
buf[len++] = '\\';
|
|
|
|
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
|
|
|
|
|
|
|
|
file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1;
|
|
|
|
bindf = 0;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
bindf = BINDF_FROMURLMON;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
|
|
|
|
memcpy(buf, wszFile2, sizeof(wszFile2));
|
2008-05-10 14:20:43 +02:00
|
|
|
len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
|
|
|
|
file_name_buf[len++] = '\\';
|
|
|
|
memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
|
|
|
|
lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf);
|
|
|
|
file_name = file_name_buf;
|
2005-12-26 12:59:31 +01:00
|
|
|
bindf = 0;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
bindf = BINDF_FROMURLMON;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
|
2008-05-10 14:20:43 +02:00
|
|
|
buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|';
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
|
2005-12-26 12:59:31 +01:00
|
|
|
memcpy(buf, wszFile3, sizeof(wszFile3));
|
|
|
|
len = sizeof(wszFile3)/sizeof(WCHAR)-1;
|
|
|
|
len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
|
|
|
|
buf[len++] = '\\';
|
|
|
|
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
|
2005-12-19 09:57:25 +01:00
|
|
|
|
2005-12-26 12:59:31 +01:00
|
|
|
file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1;
|
2005-12-19 09:57:25 +01:00
|
|
|
bindf = 0;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
bindf = BINDF_FROMURLMON;
|
|
|
|
test_file_protocol_url(buf);
|
|
|
|
|
|
|
|
DeleteFileW(wszIndexHtml);
|
|
|
|
|
|
|
|
bindf = 0;
|
|
|
|
test_file_protocol_fail();
|
|
|
|
bindf = BINDF_FROMURLMON;
|
|
|
|
test_file_protocol_fail();
|
|
|
|
}
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
static BOOL http_protocol_start(LPCWSTR url, BOOL is_first)
|
|
|
|
{
|
2007-07-19 02:59:06 +02:00
|
|
|
static BOOL got_user_agent = FALSE;
|
2005-12-31 13:32:40 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
first_data_notif = TRUE;
|
2007-07-19 02:59:06 +02:00
|
|
|
state = 0;
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
2007-07-19 03:00:20 +02:00
|
|
|
if (!(bindf & BINDF_FROMURLMON))
|
|
|
|
SET_EXPECT(ReportProgress_DIRECTBIND);
|
2005-12-31 13:32:40 +01:00
|
|
|
SET_EXPECT(GetBindString_USER_AGENT);
|
|
|
|
SET_EXPECT(GetBindString_ACCEPT_MIMES);
|
|
|
|
SET_EXPECT(QueryService_HttpNegotiate);
|
|
|
|
SET_EXPECT(BeginningTransaction);
|
|
|
|
SET_EXPECT(GetRootSecurityId);
|
2007-07-21 02:55:32 +02:00
|
|
|
if (http_post_test)
|
|
|
|
SET_EXPECT(GetBindString_POST_COOKIE);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
hres = IInternetProtocol_Start(async_protocol, url, &protocol_sink, &bind_info, 0, 0);
|
2007-07-10 17:52:03 +02:00
|
|
|
ok(hres == S_OK, "Start failed: %08x\n", hres);
|
2005-12-31 13:32:40 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
CHECK_CALLED(GetBindInfo);
|
2007-07-19 03:00:20 +02:00
|
|
|
if (!(bindf & BINDF_FROMURLMON))
|
|
|
|
CHECK_CALLED(ReportProgress_DIRECTBIND);
|
2007-07-19 02:59:06 +02:00
|
|
|
if (!got_user_agent)
|
|
|
|
{
|
|
|
|
CHECK_CALLED(GetBindString_USER_AGENT);
|
|
|
|
got_user_agent = TRUE;
|
|
|
|
}
|
|
|
|
else todo_wine
|
|
|
|
{
|
|
|
|
/* user agent only retrieved once, even with different URLs */
|
|
|
|
CHECK_NOT_CALLED(GetBindString_USER_AGENT);
|
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
CHECK_CALLED(GetBindString_ACCEPT_MIMES);
|
|
|
|
CHECK_CALLED(QueryService_HttpNegotiate);
|
|
|
|
CHECK_CALLED(BeginningTransaction);
|
2007-07-19 02:58:32 +02:00
|
|
|
/* GetRootSecurityId called on WinXP but not on Win98 */
|
|
|
|
CLEAR_CALLED(GetRootSecurityId);
|
2007-07-21 02:56:12 +02:00
|
|
|
if (http_post_test)
|
2007-07-21 02:55:32 +02:00
|
|
|
CHECK_CALLED(GetBindString_POST_COOKIE);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
static void test_protocol_terminate(IInternetProtocol *protocol)
|
|
|
|
{
|
|
|
|
BYTE buf[3600];
|
|
|
|
DWORD cb;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_LockRequest(protocol, 0);
|
|
|
|
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Read(protocol, buf, 1, &cb);
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
|
|
|
|
/* This wait is to give the internet handles being freed in Terminate
|
|
|
|
* enough time to actually terminate in all cases. Internet handles
|
|
|
|
* terminate asynchronously and native reuses the main InternetOpen
|
|
|
|
* handle. The only case in which this seems to be necessary is on
|
|
|
|
* wine with native wininet and urlmon, resulting in the next time
|
|
|
|
* test_http_protocol_url being called the first data notification actually
|
|
|
|
* being an extra last data notification from the previous connection
|
|
|
|
* about once out of every ten times. */
|
|
|
|
Sleep(100);
|
|
|
|
|
|
|
|
hres = IInternetProtocol_UnlockRequest(protocol);
|
|
|
|
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
2009-03-29 21:30:29 +02:00
|
|
|
static void test_http_info(IInternetProtocol *protocol)
|
|
|
|
{
|
|
|
|
IWinInetHttpInfo *info;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetHttpInfo, (void**)&info);
|
|
|
|
ok(hres == S_OK, "Could not get IWinInterHttpInfo iface: %08x\n", hres);
|
|
|
|
|
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
IWinInetHttpInfo_Release(info);
|
|
|
|
}
|
|
|
|
|
2007-07-19 02:59:06 +02:00
|
|
|
/* is_first refers to whether this is the first call to this function
|
|
|
|
* _for this url_ */
|
2009-01-12 18:20:06 +01:00
|
|
|
static void test_http_protocol_url(LPCWSTR url, BOOL is_https, BOOL is_first)
|
2005-11-09 11:28:26 +01:00
|
|
|
{
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
IClassFactory *factory;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2005-12-31 13:32:40 +01:00
|
|
|
http_url = url;
|
2007-07-19 02:59:06 +02:00
|
|
|
http_is_first = is_first;
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2009-01-12 18:20:06 +01:00
|
|
|
hres = CoGetClassObject(is_https ? &CLSID_HttpSProtocol : &CLSID_HttpProtocol,
|
|
|
|
CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
|
2008-10-08 01:34:35 +02:00
|
|
|
if(FAILED(hres))
|
2005-11-09 11:28:26 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
|
|
|
|
ok(hres == E_NOINTERFACE,
|
2006-10-07 15:30:28 +02:00
|
|
|
"Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
|
2005-12-31 13:32:40 +01:00
|
|
|
hres);
|
2005-11-09 11:28:26 +01:00
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
|
|
|
|
ok(hres == S_OK, "Could not get IClassFactory interface\n");
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
|
2009-03-04 19:06:06 +01:00
|
|
|
(void**)&async_protocol);
|
2006-10-07 15:30:28 +02:00
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
2005-12-31 13:32:40 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
2007-07-27 07:44:33 +02:00
|
|
|
BYTE buf[3600];
|
2005-12-31 13:32:40 +01:00
|
|
|
DWORD cb;
|
2009-03-04 19:06:06 +01:00
|
|
|
ULONG ref;
|
2005-11-09 11:28:26 +01:00
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
test_priority(async_protocol);
|
2009-03-29 21:30:29 +02:00
|
|
|
test_http_info(async_protocol);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
|
|
|
SET_EXPECT(ReportProgress_FINDINGRESOURCE);
|
|
|
|
SET_EXPECT(ReportProgress_CONNECTING);
|
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
2009-01-20 02:56:46 +01:00
|
|
|
SET_EXPECT(ReportProgress_PROXYDETECTING);
|
|
|
|
if(! is_https)
|
|
|
|
SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
|
2009-04-07 12:22:14 +02:00
|
|
|
else
|
|
|
|
SET_EXPECT(QueryService_HttpSecurity);
|
2007-07-27 07:44:33 +02:00
|
|
|
if(!(bindf & BINDF_FROMURLMON)) {
|
2007-07-19 03:00:20 +02:00
|
|
|
SET_EXPECT(OnResponse);
|
|
|
|
SET_EXPECT(ReportProgress_RAWMIMETYPE);
|
|
|
|
SET_EXPECT(ReportData);
|
2007-07-27 07:44:33 +02:00
|
|
|
} else {
|
|
|
|
SET_EXPECT(Switch);
|
2007-07-19 03:00:20 +02:00
|
|
|
}
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2007-07-19 02:59:06 +02:00
|
|
|
if(!http_protocol_start(url, is_first))
|
2005-12-31 13:32:40 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
expect_hrResult = S_OK;
|
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
|
2008-09-28 17:38:05 +02:00
|
|
|
ok((hres == E_PENDING && cb==0) ||
|
|
|
|
(hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
|
2007-07-26 07:02:17 +02:00
|
|
|
|
2007-07-27 07:44:33 +02:00
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
|
|
|
if(bindf & BINDF_FROMURLMON)
|
2007-07-19 03:00:20 +02:00
|
|
|
CHECK_CALLED(Switch);
|
2007-07-26 07:02:17 +02:00
|
|
|
else
|
2007-07-27 07:44:33 +02:00
|
|
|
CHECK_CALLED(ReportData);
|
2009-04-07 12:22:14 +02:00
|
|
|
if (is_https)
|
|
|
|
CLEAR_CALLED(QueryService_HttpSecurity);
|
2007-07-26 07:02:17 +02:00
|
|
|
|
2007-07-27 07:44:33 +02:00
|
|
|
while(1) {
|
|
|
|
if(bindf & BINDF_FROMURLMON)
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
else
|
|
|
|
SET_EXPECT(ReportData);
|
2009-03-04 19:06:06 +01:00
|
|
|
hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
|
2007-07-27 07:44:33 +02:00
|
|
|
if(hres == E_PENDING) {
|
2009-03-04 19:06:06 +01:00
|
|
|
hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
|
2008-09-28 17:38:05 +02:00
|
|
|
ok((hres == E_PENDING && cb==0) ||
|
|
|
|
(hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
|
2007-07-27 07:44:33 +02:00
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
|
|
|
if(bindf & BINDF_FROMURLMON)
|
|
|
|
CHECK_CALLED(Switch);
|
|
|
|
else
|
|
|
|
CHECK_CALLED(ReportData);
|
2009-03-04 19:06:06 +01:00
|
|
|
}else {
|
2007-07-27 07:44:33 +02:00
|
|
|
if(bindf & BINDF_FROMURLMON)
|
|
|
|
CHECK_NOT_CALLED(Switch);
|
|
|
|
else
|
|
|
|
CHECK_NOT_CALLED(ReportData);
|
|
|
|
if(cb == 0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
2005-12-31 13:32:40 +01:00
|
|
|
CHECK_CALLED(ReportResult);
|
2009-04-07 12:22:14 +02:00
|
|
|
if (is_https)
|
|
|
|
CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
test_protocol_terminate(async_protocol);
|
|
|
|
ref = IInternetProtocol_Release(async_protocol);
|
|
|
|
ok(!ref, "ref=%x\n", hres);
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_http_protocol(void)
|
|
|
|
{
|
|
|
|
static const WCHAR winehq_url[] =
|
|
|
|
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
|
|
|
|
'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
|
2007-07-21 02:55:32 +02:00
|
|
|
static const WCHAR posttest_url[] =
|
|
|
|
{'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
|
|
|
|
'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
|
|
|
|
'p','o','s','t','t','e','s','t','.','p','h','p',0};
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
trace("Testing http protocol (not from urlmon)...\n");
|
2005-12-31 13:32:40 +01:00
|
|
|
tested_protocol = HTTP_TEST;
|
2007-07-19 03:00:20 +02:00
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
|
2009-01-12 18:20:06 +01:00
|
|
|
test_http_protocol_url(winehq_url, FALSE, TRUE);
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
trace("Testing http protocol (from urlmon)...\n");
|
2007-07-19 03:00:20 +02:00
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON;
|
2009-01-12 18:20:06 +01:00
|
|
|
test_http_protocol_url(winehq_url, FALSE, FALSE);
|
2005-11-09 11:28:26 +01:00
|
|
|
|
2008-01-31 18:18:49 +01:00
|
|
|
trace("Testing http protocol (to file)...\n");
|
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NEEDFILE;
|
2009-01-12 18:20:06 +01:00
|
|
|
test_http_protocol_url(winehq_url, FALSE, FALSE);
|
2008-01-31 18:18:49 +01:00
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
trace("Testing http protocol (post data)...\n");
|
2007-07-21 02:55:32 +02:00
|
|
|
http_post_test = TRUE;
|
|
|
|
/* Without this flag we get a ReportProgress_CACHEFILENAMEAVAILABLE
|
|
|
|
* notification with BINDVERB_POST */
|
2008-01-31 18:18:49 +01:00
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
|
2009-01-12 18:20:06 +01:00
|
|
|
test_http_protocol_url(posttest_url, FALSE, TRUE);
|
2007-07-21 02:55:32 +02:00
|
|
|
http_post_test = FALSE;
|
2005-12-31 13:32:40 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 18:20:06 +01:00
|
|
|
static void test_https_protocol(void)
|
|
|
|
{
|
|
|
|
static const WCHAR codeweavers_url[] =
|
|
|
|
{'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
|
|
|
|
'.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
|
|
|
|
|
|
|
|
trace("Testing https protocol (from urlmon)...\n");
|
|
|
|
tested_protocol = HTTPS_TEST;
|
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
|
|
|
|
test_http_protocol_url(codeweavers_url, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
|
2009-03-04 19:06:06 +01:00
|
|
|
|
|
|
|
static void test_ftp_protocol(void)
|
|
|
|
{
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
IClassFactory *factory;
|
|
|
|
IUnknown *unk;
|
|
|
|
BYTE buf[4096];
|
|
|
|
ULONG ref;
|
|
|
|
DWORD cb;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
|
|
|
|
'/','p','u','b','/','o','t','h','e','r','/',
|
|
|
|
'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
|
|
|
|
|
|
|
|
trace("Testing ftp protocol...\n");
|
|
|
|
|
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
|
|
|
|
state = 0;
|
|
|
|
tested_protocol = FTP_TEST;
|
|
|
|
first_data_notif = TRUE;
|
|
|
|
expect_hrResult = E_PENDING;
|
|
|
|
|
|
|
|
hres = CoGetClassObject(&CLSID_FtpProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
|
|
|
|
ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
|
|
|
|
ok(hres == S_OK, "Could not get IClassFactory interface\n");
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
|
|
|
|
(void**)&async_protocol);
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
|
|
|
|
|
|
|
test_priority(async_protocol);
|
2009-03-29 21:30:50 +02:00
|
|
|
test_http_info(async_protocol);
|
2009-03-04 19:06:06 +01:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
SET_EXPECT(GetBindString_USER_AGENT);
|
|
|
|
SET_EXPECT(ReportProgress_FINDINGRESOURCE);
|
|
|
|
SET_EXPECT(ReportProgress_CONNECTING);
|
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
|
|
|
SET_EXPECT(Switch);
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Start(async_protocol, ftp_urlW, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == S_OK, "Start failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(GetBindInfo);
|
|
|
|
todo_wine CHECK_NOT_CALLED(GetBindString_USER_AGENT);
|
|
|
|
|
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
|
|
|
|
ok((hres == E_PENDING && cb==0) ||
|
|
|
|
(hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
|
|
|
|
|
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
|
2009-03-30 00:41:54 +02:00
|
|
|
if(hres == E_PENDING)
|
2009-03-04 19:06:06 +01:00
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
2009-03-30 00:41:54 +02:00
|
|
|
else
|
2009-03-04 19:06:06 +01:00
|
|
|
if(cb == 0) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(ReportResult);
|
2009-03-30 00:41:54 +02:00
|
|
|
CHECK_CALLED(Switch);
|
2009-03-04 19:06:06 +01:00
|
|
|
|
|
|
|
test_protocol_terminate(async_protocol);
|
|
|
|
|
|
|
|
ref = IInternetProtocol_Release(async_protocol);
|
|
|
|
ok(!ref, "ref=%d\n", ref);
|
|
|
|
}
|
|
|
|
|
2009-03-04 19:06:42 +01:00
|
|
|
static void test_gopher_protocol(void)
|
|
|
|
{
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
IClassFactory *factory;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
trace("Testing gopher protocol...\n");
|
|
|
|
|
|
|
|
hres = CoGetClassObject(&CLSID_GopherProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
|
2009-03-19 11:16:28 +01:00
|
|
|
ok(hres == S_OK ||
|
|
|
|
hres == REGDB_E_CLASSNOTREG, /* Gopher protocol has been removed as of Vista */
|
|
|
|
"CoGetClassObject failed: %08x\n", hres);
|
2009-03-04 19:06:42 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
|
|
|
|
ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
|
|
|
|
ok(hres == S_OK, "Could not get IClassFactory interface\n");
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
|
|
|
|
(void**)&async_protocol);
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
|
|
|
|
2009-03-04 19:07:05 +01:00
|
|
|
test_priority(async_protocol);
|
|
|
|
|
2009-03-04 19:06:42 +01:00
|
|
|
IInternetProtocol_Release(async_protocol);
|
|
|
|
}
|
|
|
|
|
2007-01-12 12:31:54 +01:00
|
|
|
static void test_mk_protocol(void)
|
|
|
|
{
|
|
|
|
IInternetProtocolInfo *protocol_info;
|
|
|
|
IInternetProtocol *protocol;
|
|
|
|
IClassFactory *factory;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2007-01-13 12:46:06 +01:00
|
|
|
static const WCHAR wrong_url1[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
|
|
|
|
':',':','/','t','e','s','t','.','h','t','m','l',0};
|
|
|
|
static const WCHAR wrong_url2[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
trace("Testing mk protocol...\n");
|
2007-01-13 12:46:06 +01:00
|
|
|
tested_protocol = MK_TEST;
|
|
|
|
|
2007-01-12 12:31:54 +01:00
|
|
|
hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
|
|
|
|
ok(hres == E_NOINTERFACE,
|
|
|
|
"Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
|
|
|
|
hres);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
|
|
|
|
ok(hres == S_OK, "Could not get IClassFactory interface\n");
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
|
|
|
|
(void**)&protocol);
|
|
|
|
IClassFactory_Release(factory);
|
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
|
|
|
|
|
2007-01-13 12:46:06 +01:00
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
hres = IInternetProtocol_Start(protocol, wrong_url1, &protocol_sink, &bind_info, 0, 0);
|
2007-10-25 22:26:32 +02:00
|
|
|
ok(hres == MK_E_SYNTAX || hres == INET_E_INVALID_URL,
|
|
|
|
"Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres);
|
|
|
|
CLEAR_CALLED(GetBindInfo);
|
2007-01-13 12:46:06 +01:00
|
|
|
|
|
|
|
SET_EXPECT(GetBindInfo);
|
|
|
|
SET_EXPECT(ReportProgress_DIRECTBIND);
|
|
|
|
SET_EXPECT(ReportProgress_SENDINGREQUEST);
|
|
|
|
SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
SET_EXPECT(ReportResult);
|
|
|
|
expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_Start(protocol, wrong_url2, &protocol_sink, &bind_info, 0, 0);
|
2008-06-01 04:10:54 +02:00
|
|
|
ok(hres == INET_E_RESOURCE_NOT_FOUND ||
|
|
|
|
hres == INET_E_INVALID_URL, /* win2k3 */
|
|
|
|
"Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres);
|
2007-01-13 12:46:06 +01:00
|
|
|
|
2008-06-06 20:28:25 +02:00
|
|
|
if (hres == INET_E_RESOURCE_NOT_FOUND) {
|
2008-06-01 04:10:54 +02:00
|
|
|
CHECK_CALLED(GetBindInfo);
|
|
|
|
CLEAR_CALLED(ReportProgress_DIRECTBIND);
|
|
|
|
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
CHECK_CALLED(ReportResult);
|
2008-06-06 20:28:25 +02:00
|
|
|
}else {
|
|
|
|
CLEAR_CALLED(GetBindInfo);
|
|
|
|
CLEAR_CALLED(ReportProgress_DIRECTBIND);
|
|
|
|
CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
|
|
|
|
CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE);
|
|
|
|
CLEAR_CALLED(ReportResult);
|
2008-06-01 04:10:54 +02:00
|
|
|
}
|
2007-01-13 12:46:06 +01:00
|
|
|
|
2007-01-12 12:31:54 +01:00
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
static void test_CreateBinding(void)
|
|
|
|
{
|
2007-12-24 12:43:35 +01:00
|
|
|
IInternetProtocolSink *sink;
|
2007-01-23 19:36:38 +01:00
|
|
|
IInternetProtocol *protocol;
|
2007-01-23 23:33:38 +01:00
|
|
|
IInternetPriority *priority;
|
2007-01-23 19:36:38 +01:00
|
|
|
IInternetSession *session;
|
2007-01-23 23:33:38 +01:00
|
|
|
LONG p;
|
2007-01-23 19:36:38 +01:00
|
|
|
BYTE buf[1000];
|
|
|
|
DWORD read;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR test_url[] =
|
|
|
|
{'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
|
|
|
|
static const WCHAR wsz_test[] = {'t','e','s','t',0};
|
|
|
|
|
|
|
|
trace("Testing CreateBinding...\n");
|
|
|
|
tested_protocol = BIND_TEST;
|
2007-12-24 12:43:35 +01:00
|
|
|
binding_test = TRUE;
|
2007-01-23 19:36:38 +01:00
|
|
|
|
|
|
|
hres = CoInternetGetSession(0, &session, 0);
|
|
|
|
ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, wsz_test, 0, NULL, 0);
|
|
|
|
ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0);
|
2007-12-28 14:54:48 +01:00
|
|
|
binding_protocol = protocol;
|
2007-01-23 19:36:38 +01:00
|
|
|
ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
|
|
|
|
ok(protocol != NULL, "protocol == NULL\n");
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&sink);
|
|
|
|
ok(hres == S_OK, "Could not get IInternetProtocolSink: %08x\n", hres);
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
hres = IInternetProtocol_Start(protocol, test_url, NULL, &bind_info, 0, 0);
|
|
|
|
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
|
|
|
|
hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, NULL, 0, 0);
|
|
|
|
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
|
|
|
|
hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
|
|
|
|
|
2007-01-23 23:33:38 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
p = 0xdeadbeef;
|
|
|
|
hres = IInternetPriority_GetPriority(priority, &p);
|
|
|
|
ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
|
|
|
|
ok(!p, "p=%d\n", p);
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
ex_priority = 100;
|
2007-01-23 23:33:38 +01:00
|
|
|
hres = IInternetPriority_SetPriority(priority, 100);
|
|
|
|
ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
|
|
|
|
|
|
|
|
p = 0xdeadbeef;
|
|
|
|
hres = IInternetPriority_GetPriority(priority, &p);
|
|
|
|
ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
|
|
|
|
ok(p == 100, "p=%d\n", p);
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
SET_EXPECT(QueryService_InternetProtocol);
|
|
|
|
SET_EXPECT(CreateInstance);
|
|
|
|
SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
|
2007-01-23 23:33:38 +01:00
|
|
|
SET_EXPECT(SetPriority);
|
2007-01-23 19:36:38 +01:00
|
|
|
SET_EXPECT(Start);
|
|
|
|
|
|
|
|
expect_hrResult = S_OK;
|
|
|
|
hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == S_OK, "Start failed: %08x\n", hres);
|
|
|
|
|
|
|
|
CHECK_CALLED(QueryService_InternetProtocol);
|
|
|
|
CHECK_CALLED(CreateInstance);
|
|
|
|
CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
|
2007-01-23 23:33:38 +01:00
|
|
|
CHECK_CALLED(SetPriority);
|
2007-01-23 19:36:38 +01:00
|
|
|
CHECK_CALLED(Start);
|
|
|
|
|
|
|
|
SET_EXPECT(Read);
|
|
|
|
read = 0xdeadbeef;
|
|
|
|
hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
|
|
|
|
ok(hres == S_OK, "Read failed: %08x\n", hres);
|
|
|
|
ok(read == 100, "read = %d\n", read);
|
|
|
|
CHECK_CALLED(Read);
|
|
|
|
|
|
|
|
SET_EXPECT(Read);
|
|
|
|
read = 0xdeadbeef;
|
|
|
|
hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
|
|
|
|
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
|
|
|
|
ok(!read, "read = %d\n", read);
|
|
|
|
CHECK_CALLED(Read);
|
|
|
|
|
2007-01-23 23:33:38 +01:00
|
|
|
p = 0xdeadbeef;
|
|
|
|
hres = IInternetPriority_GetPriority(priority, &p);
|
|
|
|
ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
|
|
|
|
ok(p == 100, "p=%d\n", p);
|
|
|
|
|
|
|
|
hres = IInternetPriority_SetPriority(priority, 101);
|
|
|
|
ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
|
|
|
|
|
2007-01-23 19:36:38 +01:00
|
|
|
SET_EXPECT(Terminate);
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0xdeadbeef);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(Terminate);
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
SET_EXPECT(Continue);
|
|
|
|
hres = IInternetProtocolSink_Switch(sink, &protocoldata);
|
|
|
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(Continue);
|
|
|
|
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(sink,
|
|
|
|
BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
|
|
|
|
ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetProtocolSink_ReportResult(sink, S_OK, ERROR_SUCCESS, NULL);
|
|
|
|
ok(hres == E_FAIL, "ReportResult failed: %08x, expected E_FAIL\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetProtocolSink_ReportData(sink, 0, 0, 0);
|
|
|
|
ok(hres == S_OK, "ReportData failed: %08x\n", hres);
|
|
|
|
|
|
|
|
IInternetProtocolSink_Release(sink);
|
2007-01-23 23:33:38 +01:00
|
|
|
IInternetPriority_Release(priority);
|
2007-01-23 19:36:38 +01:00
|
|
|
IInternetBindInfo_Release(prot_bind_info);
|
|
|
|
IInternetProtocol_Release(protocol);
|
|
|
|
IInternetSession_Release(session);
|
|
|
|
}
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
static void test_binding(int prot)
|
|
|
|
{
|
|
|
|
IInternetProtocol *protocol;
|
|
|
|
IInternetSession *session;
|
2007-12-28 14:54:48 +01:00
|
|
|
ULONG ref;
|
2007-12-24 12:43:35 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
trace("Testing %s binding...\n", debugstr_w(protocol_names[prot]));
|
|
|
|
|
|
|
|
tested_protocol = prot;
|
|
|
|
binding_test = TRUE;
|
|
|
|
first_data_notif = TRUE;
|
2007-12-28 14:54:48 +01:00
|
|
|
prot_read = 0;
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
hres = CoInternetGetSession(0, &session, 0);
|
|
|
|
ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, protocol_names[prot], 0, NULL, 0);
|
|
|
|
ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
|
|
|
|
|
|
|
|
hres = IInternetSession_CreateBinding(session, NULL, binding_urls[prot], NULL, NULL, &protocol, 0);
|
2007-12-28 14:54:48 +01:00
|
|
|
binding_protocol = protocol;
|
2007-12-24 12:43:35 +01:00
|
|
|
IInternetSession_Release(session);
|
|
|
|
ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
|
|
|
|
ok(protocol != NULL, "protocol == NULL\n");
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink);
|
|
|
|
ok(hres == S_OK, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres);
|
2007-12-24 12:43:35 +01:00
|
|
|
|
|
|
|
ex_priority = 0;
|
|
|
|
SET_EXPECT(QueryService_InternetProtocol);
|
|
|
|
SET_EXPECT(CreateInstance);
|
|
|
|
SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
|
|
|
|
SET_EXPECT(SetPriority);
|
|
|
|
SET_EXPECT(Start);
|
|
|
|
|
|
|
|
expect_hrResult = S_OK;
|
|
|
|
hres = IInternetProtocol_Start(protocol, binding_urls[prot], &protocol_sink, &bind_info, 0, 0);
|
|
|
|
ok(hres == S_OK, "Start failed: %08x\n", hres);
|
|
|
|
|
|
|
|
CHECK_CALLED(QueryService_InternetProtocol);
|
|
|
|
CHECK_CALLED(CreateInstance);
|
|
|
|
CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
|
|
|
|
CHECK_CALLED(SetPriority);
|
|
|
|
CHECK_CALLED(Start);
|
|
|
|
|
2009-01-12 18:20:06 +01:00
|
|
|
if(prot == HTTP_TEST || prot == HTTPS_TEST) {
|
2007-12-28 14:54:48 +01:00
|
|
|
while(prot_state < 4) {
|
2007-12-24 12:43:35 +01:00
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
|
|
|
SET_EXPECT(Continue);
|
|
|
|
IInternetProtocol_Continue(protocol, pdata);
|
|
|
|
CHECK_CALLED(Continue);
|
|
|
|
SetEvent(event_complete2);
|
|
|
|
}
|
2007-12-28 14:54:48 +01:00
|
|
|
|
|
|
|
WaitForSingleObject(event_complete, INFINITE);
|
2007-12-24 12:43:35 +01:00
|
|
|
}else {
|
|
|
|
SET_EXPECT(LockRequest);
|
|
|
|
hres = IInternetProtocol_LockRequest(protocol, 0);
|
|
|
|
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(LockRequest);
|
|
|
|
|
|
|
|
SET_EXPECT(UnlockRequest);
|
|
|
|
hres = IInternetProtocol_UnlockRequest(protocol);
|
|
|
|
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(UnlockRequest);
|
|
|
|
}
|
|
|
|
|
2007-12-28 14:54:48 +01:00
|
|
|
SET_EXPECT(Terminate);
|
|
|
|
hres = IInternetProtocol_Terminate(protocol, 0);
|
|
|
|
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
|
|
|
|
CHECK_CALLED(Terminate);
|
|
|
|
|
2007-12-24 12:43:35 +01:00
|
|
|
IInternetBindInfo_Release(prot_bind_info);
|
2007-12-28 14:54:48 +01:00
|
|
|
IInternetProtocolSink_Release(binding_sink);
|
|
|
|
ref = IInternetProtocol_Release(protocol);
|
|
|
|
ok(!ref, "ref=%u, expected 0\n", ref);
|
2007-12-24 12:43:35 +01:00
|
|
|
}
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
START_TEST(protocol)
|
|
|
|
{
|
|
|
|
OleInitialize(NULL);
|
|
|
|
|
2007-07-27 07:39:17 +02:00
|
|
|
event_complete = CreateEvent(NULL, FALSE, FALSE, NULL);
|
2007-12-24 12:43:35 +01:00
|
|
|
event_complete2 = CreateEvent(NULL, FALSE, FALSE, NULL);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
test_file_protocol();
|
2005-11-09 11:28:26 +01:00
|
|
|
test_http_protocol();
|
2009-01-12 18:20:06 +01:00
|
|
|
test_https_protocol();
|
2009-03-04 19:06:06 +01:00
|
|
|
test_ftp_protocol();
|
2009-03-04 19:06:42 +01:00
|
|
|
test_gopher_protocol();
|
2007-01-12 12:31:54 +01:00
|
|
|
test_mk_protocol();
|
2007-01-23 19:36:38 +01:00
|
|
|
test_CreateBinding();
|
2007-12-24 12:43:35 +01:00
|
|
|
test_binding(FILE_TEST);
|
|
|
|
test_binding(HTTP_TEST);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2007-07-27 07:39:17 +02:00
|
|
|
CloseHandle(event_complete);
|
2007-12-24 12:43:35 +01:00
|
|
|
CloseHandle(event_complete2);
|
2005-12-31 13:32:40 +01:00
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
OleUninitialize();
|
|
|
|
}
|