Commit 954e55b5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added https pluggable protocol handler.

parent 1e06fcdc
...@@ -63,6 +63,7 @@ typedef struct { ...@@ -63,6 +63,7 @@ typedef struct {
const IInternetProtocolVtbl *lpInternetProtocolVtbl; const IInternetProtocolVtbl *lpInternetProtocolVtbl;
const IInternetPriorityVtbl *lpInternetPriorityVtbl; const IInternetPriorityVtbl *lpInternetPriorityVtbl;
BOOL https;
DWORD flags, grfBINDF; DWORD flags, grfBINDF;
BINDINFO bind_info; BINDINFO bind_info;
IInternetProtocolSink *protocol_sink; IInternetProtocolSink *protocol_sink;
...@@ -309,7 +310,8 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl ...@@ -309,7 +310,8 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
LPOLESTR user_agent = NULL, accept_mimes[257]; LPOLESTR user_agent = NULL, accept_mimes[257];
HRESULT hres; HRESULT hres;
static const WCHAR wszHttp[] = {'h','t','t','p',':'}; static const WCHAR httpW[] = {'h','t','t','p',':'};
static const WCHAR httpsW[] = {'h','t','t','p','s',':'};
static const WCHAR wszBindVerb[BINDVERB_CUSTOM][5] = static const WCHAR wszBindVerb[BINDVERB_CUSTOM][5] =
{{'G','E','T',0}, {{'G','E','T',0},
{'P','O','S','T',0}, {'P','O','S','T',0},
...@@ -330,8 +332,9 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl ...@@ -330,8 +332,9 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
goto done; goto done;
} }
if (strlenW(szUrl) < sizeof(wszHttp)/sizeof(WCHAR) if(This->https
|| memcmp(szUrl, wszHttp, sizeof(wszHttp))) ? strncmpW(szUrl, httpsW, sizeof(httpsW)/sizeof(WCHAR))
: strncmpW(szUrl, httpW, sizeof(httpW)/sizeof(WCHAR)))
{ {
hres = MK_E_SYNTAX; hres = MK_E_SYNTAX;
goto done; goto done;
...@@ -351,7 +354,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl ...@@ -351,7 +354,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
user = strndupW(url.lpszUserName, url.dwUserNameLength); user = strndupW(url.lpszUserName, url.dwUserNameLength);
pass = strndupW(url.lpszPassword, url.dwPasswordLength); pass = strndupW(url.lpszPassword, url.dwPasswordLength);
if (!url.nPort) if (!url.nPort)
url.nPort = INTERNET_DEFAULT_HTTP_PORT; url.nPort = This->https ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;
if(!(This->grfBINDF & BINDF_FROMURLMON)) if(!(This->grfBINDF & BINDF_FROMURLMON))
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_DIRECTBIND, NULL); IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_DIRECTBIND, NULL);
...@@ -397,7 +400,9 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl ...@@ -397,7 +400,9 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
InternetSetStatusCallbackW(This->internet, HTTPPROTOCOL_InternetStatusCallback); InternetSetStatusCallbackW(This->internet, HTTPPROTOCOL_InternetStatusCallback);
This->connect = InternetConnectW(This->internet, host, url.nPort, user, This->connect = InternetConnectW(This->internet, host, url.nPort, user,
pass, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)This); pass, INTERNET_SERVICE_HTTP,
This->https ? INTERNET_FLAG_SECURE : 0,
(DWORD_PTR)This);
if (!This->connect) if (!This->connect)
{ {
WARN("InternetConnect failed: %d\n", GetLastError()); WARN("InternetConnect failed: %d\n", GetLastError());
...@@ -421,6 +426,8 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl ...@@ -421,6 +426,8 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
request_flags |= INTERNET_FLAG_NO_CACHE_WRITE; request_flags |= INTERNET_FLAG_NO_CACHE_WRITE;
if (This->grfBINDF & BINDF_NEEDFILE) if (This->grfBINDF & BINDF_NEEDFILE)
request_flags |= INTERNET_FLAG_NEED_FILE; request_flags |= INTERNET_FLAG_NEED_FILE;
if (This->https)
request_flags |= INTERNET_FLAG_SECURE;
This->request = HttpOpenRequestW(This->connect, This->bind_info.dwBindVerb < BINDVERB_CUSTOM ? This->request = HttpOpenRequestW(This->connect, This->bind_info.dwBindVerb < BINDVERB_CUSTOM ?
wszBindVerb[This->bind_info.dwBindVerb] : wszBindVerb[This->bind_info.dwBindVerb] :
This->bind_info.szCustomVerb, This->bind_info.szCustomVerb,
...@@ -923,36 +930,36 @@ static const IInternetProtocolVtbl HttpProtocolVtbl = { ...@@ -923,36 +930,36 @@ static const IInternetProtocolVtbl HttpProtocolVtbl = {
HttpProtocol_UnlockRequest HttpProtocol_UnlockRequest
}; };
HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) HRESULT create_http_protocol(BOOL https, void **ppobj)
{ {
HttpProtocol *ret; HttpProtocol *ret;
TRACE("(%p %p)\n", pUnkOuter, ppobj); ret = heap_alloc_zero(sizeof(HttpProtocol));
if(!ret)
URLMON_LockModule(); return E_OUTOFMEMORY;
ret = heap_alloc(sizeof(HttpProtocol));
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl; ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
ret->lpInternetPriorityVtbl = &HttpPriorityVtbl; ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
ret->flags = ret->grfBINDF = 0;
memset(&ret->bind_info, 0, sizeof(ret->bind_info)); ret->https = https;
ret->protocol_sink = 0;
ret->http_negotiate = 0;
ret->internet = ret->connect = ret->request = 0;
ret->full_header = 0;
ret->lock = 0;
ret->current_position = ret->content_length = ret->available_bytes = 0;
ret->priority = 0;
ret->ref = 1; ret->ref = 1;
*ppobj = PROTOCOL(ret); *ppobj = PROTOCOL(ret);
URLMON_LockModule();
return S_OK; return S_OK;
} }
HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
{
TRACE("(%p %p)\n", pUnkOuter, ppobj);
return create_http_protocol(FALSE, ppobj);
}
HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
{ {
FIXME("(%p %p)\n", pUnkOuter, ppobj); TRACE("(%p %p)\n", pUnkOuter, ppobj);
return E_NOINTERFACE;
return create_http_protocol(TRUE, ppobj);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment