d3dcompiler: Add D3D_BLOB_LEGACY_SHADER to D3DGetBlobPart().
[wine.git] / dlls / urlmon / http.c
blob296efb650645251bd9026fecf808fe6bc05c51e0
1 /*
2 * Copyright 2005 Jacek Caban
3 * Copyright 2007 Misha Koshelev
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "urlmon_main.h"
21 #include "wininet.h"
23 #define NO_SHLWAPI_REG
24 #include "shlwapi.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
30 typedef struct {
31 Protocol base;
33 const IInternetProtocolExVtbl *lpIInternetProtocolExVtbl;
34 const IInternetPriorityVtbl *lpInternetPriorityVtbl;
35 const IWinInetHttpInfoVtbl *lpWinInetHttpInfoVtbl;
37 BOOL https;
38 IHttpNegotiate *http_negotiate;
39 LPWSTR full_header;
41 LONG ref;
42 } HttpProtocol;
44 #define PROTOCOLEX(x) ((IInternetProtocolEx*)&(x)->lpIInternetProtocolExVtbl)
45 #define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
46 #define INETHTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpWinInetHttpInfoVtbl)
48 /* Default headers from native */
49 static const WCHAR wszHeaders[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',
50 ':',' ','g','z','i','p',',',' ','d','e','f','l','a','t','e',0};
52 static LPWSTR query_http_info(HttpProtocol *This, DWORD option)
54 LPWSTR ret = NULL;
55 DWORD len = 0;
56 BOOL res;
58 res = HttpQueryInfoW(This->base.request, option, NULL, &len, NULL);
59 if (!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
60 ret = heap_alloc(len);
61 res = HttpQueryInfoW(This->base.request, option, ret, &len, NULL);
63 if(!res) {
64 TRACE("HttpQueryInfoW(%d) failed: %08x\n", option, GetLastError());
65 heap_free(ret);
66 return NULL;
69 return ret;
72 #define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(HttpProtocol, base, iface)
74 static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD request_flags,
75 HINTERNET internet_session, IInternetBindInfo *bind_info)
77 HttpProtocol *This = ASYNCPROTOCOL_THIS(prot);
78 INTERNET_BUFFERSW send_buffer = {sizeof(INTERNET_BUFFERSW)};
79 LPWSTR addl_header = NULL, post_cookie = NULL;
80 IServiceProvider *service_provider = NULL;
81 IHttpNegotiate2 *http_negotiate2 = NULL;
82 BSTR url, host, user, pass, path;
83 LPOLESTR accept_mimes[257];
84 const WCHAR **accept_types;
85 BYTE security_id[512];
86 DWORD len = 0, port;
87 ULONG num;
88 BOOL res, b;
89 HRESULT hres;
91 static const WCHAR wszBindVerb[BINDVERB_CUSTOM][5] =
92 {{'G','E','T',0},
93 {'P','O','S','T',0},
94 {'P','U','T',0}};
96 hres = IUri_GetPort(uri, &port);
97 if(FAILED(hres))
98 return hres;
100 hres = IUri_GetHost(uri, &host);
101 if(FAILED(hres))
102 return hres;
104 hres = IUri_GetUserName(uri, &user);
105 if(SUCCEEDED(hres)) {
106 hres = IUri_GetPassword(uri, &pass);
108 if(SUCCEEDED(hres)) {
109 This->base.connection = InternetConnectW(internet_session, host, port, user, pass,
110 INTERNET_SERVICE_HTTP, This->https ? INTERNET_FLAG_SECURE : 0, (DWORD_PTR)&This->base);
111 SysFreeString(pass);
113 SysFreeString(user);
115 SysFreeString(host);
116 if(FAILED(hres))
117 return hres;
118 if(!This->base.connection) {
119 WARN("InternetConnect failed: %d\n", GetLastError());
120 return INET_E_CANNOT_CONNECT;
123 num = sizeof(accept_mimes)/sizeof(accept_mimes[0])-1;
124 hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_ACCEPT_MIMES, accept_mimes, num, &num);
125 if(hres == INET_E_USE_DEFAULT_SETTING) {
126 static const WCHAR default_accept_mimeW[] = {'*','/','*',0};
127 static const WCHAR *default_accept_mimes[] = {default_accept_mimeW, NULL};
129 accept_types = default_accept_mimes;
130 num = 0;
131 }else if(hres == S_OK) {
132 accept_types = (const WCHAR**)accept_mimes;
133 }else {
134 WARN("GetBindString BINDSTRING_ACCEPT_MIMES failed: %08x\n", hres);
135 return INET_E_NO_VALID_MEDIA;
137 accept_mimes[num] = 0;
139 if(This->https)
140 request_flags |= INTERNET_FLAG_SECURE;
142 hres = IUri_GetPathAndQuery(uri, &path);
143 if(SUCCEEDED(hres)) {
144 This->base.request = HttpOpenRequestW(This->base.connection,
145 This->base.bind_info.dwBindVerb < BINDVERB_CUSTOM
146 ? wszBindVerb[This->base.bind_info.dwBindVerb] : This->base.bind_info.szCustomVerb,
147 path, NULL, NULL, accept_types, request_flags, (DWORD_PTR)&This->base);
148 SysFreeString(path);
150 while(num--)
151 CoTaskMemFree(accept_mimes[num]);
152 if(FAILED(hres))
153 return hres;
154 if (!This->base.request) {
155 WARN("HttpOpenRequest failed: %d\n", GetLastError());
156 return INET_E_RESOURCE_NOT_FOUND;
159 hres = IInternetProtocolSink_QueryInterface(This->base.protocol_sink, &IID_IServiceProvider,
160 (void **)&service_provider);
161 if (hres != S_OK) {
162 WARN("IInternetProtocolSink_QueryInterface IID_IServiceProvider failed: %08x\n", hres);
163 return hres;
166 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
167 &IID_IHttpNegotiate, (void **)&This->http_negotiate);
168 if (hres != S_OK) {
169 WARN("IServiceProvider_QueryService IID_IHttpNegotiate failed: %08x\n", hres);
170 IServiceProvider_Release(service_provider);
171 return hres;
174 hres = IUri_GetAbsoluteUri(uri, &url);
175 if(FAILED(hres)) {
176 IServiceProvider_Release(service_provider);
177 return hres;
180 hres = IHttpNegotiate_BeginningTransaction(This->http_negotiate, url, wszHeaders,
181 0, &addl_header);
182 SysFreeString(url);
183 if(hres != S_OK) {
184 WARN("IHttpNegotiate_BeginningTransaction failed: %08x\n", hres);
185 IServiceProvider_Release(service_provider);
186 return hres;
189 if(addl_header) {
190 int len_addl_header = strlenW(addl_header);
192 This->full_header = heap_alloc(len_addl_header*sizeof(WCHAR)+sizeof(wszHeaders));
194 lstrcpyW(This->full_header, addl_header);
195 lstrcpyW(&This->full_header[len_addl_header], wszHeaders);
196 CoTaskMemFree(addl_header);
197 }else {
198 This->full_header = (LPWSTR)wszHeaders;
201 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
202 &IID_IHttpNegotiate2, (void **)&http_negotiate2);
203 IServiceProvider_Release(service_provider);
204 if(hres != S_OK) {
205 WARN("IServiceProvider_QueryService IID_IHttpNegotiate2 failed: %08x\n", hres);
206 /* No goto done as per native */
207 }else {
208 len = sizeof(security_id)/sizeof(security_id[0]);
209 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, security_id, &len, 0);
210 IHttpNegotiate2_Release(http_negotiate2);
211 if (hres != S_OK)
212 WARN("IHttpNegotiate2_GetRootSecurityId failed: %08x\n", hres);
215 /* FIXME: Handle security_id. Native calls undocumented function IsHostInProxyBypassList. */
217 if(This->base.bind_info.dwBindVerb == BINDVERB_POST) {
218 num = 0;
219 hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_POST_COOKIE, &post_cookie, 1, &num);
220 if(hres == S_OK && num) {
221 if(!InternetSetOptionW(This->base.request, INTERNET_OPTION_SECONDARY_CACHE_KEY,
222 post_cookie, lstrlenW(post_cookie)))
223 WARN("InternetSetOption INTERNET_OPTION_SECONDARY_CACHE_KEY failed: %d\n", GetLastError());
224 CoTaskMemFree(post_cookie);
228 send_buffer.lpcszHeader = This->full_header;
229 send_buffer.dwHeadersLength = send_buffer.dwHeadersTotal = strlenW(This->full_header);
231 if(This->base.bind_info.dwBindVerb != BINDVERB_GET) {
232 switch(This->base.bind_info.stgmedData.tymed) {
233 case TYMED_HGLOBAL:
234 /* Native does not use GlobalLock/GlobalUnlock, so we won't either */
235 send_buffer.lpvBuffer = This->base.bind_info.stgmedData.u.hGlobal;
236 send_buffer.dwBufferLength = send_buffer.dwBufferTotal = This->base.bind_info.cbstgmedData;
237 break;
238 case TYMED_ISTREAM: {
239 LARGE_INTEGER offset;
241 send_buffer.dwBufferTotal = This->base.bind_info.cbstgmedData;
242 This->base.post_stream = This->base.bind_info.stgmedData.u.pstm;
243 IStream_AddRef(This->base.post_stream);
245 offset.QuadPart = 0;
246 IStream_Seek(This->base.post_stream, offset, STREAM_SEEK_SET, NULL);
247 break;
249 default:
250 FIXME("Unsupported This->base.bind_info.stgmedData.tymed %d\n", This->base.bind_info.stgmedData.tymed);
254 b = TRUE;
255 res = InternetSetOptionW(This->base.request, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b));
256 if(!res)
257 WARN("InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %08x\n", GetLastError());
259 if(This->base.post_stream)
260 res = HttpSendRequestExW(This->base.request, &send_buffer, NULL, 0, 0);
261 else
262 res = HttpSendRequestW(This->base.request, send_buffer.lpcszHeader, send_buffer.dwHeadersLength,
263 send_buffer.lpvBuffer, send_buffer.dwBufferLength);
264 if(!res && GetLastError() != ERROR_IO_PENDING) {
265 WARN("HttpSendRequest failed: %d\n", GetLastError());
266 return INET_E_DOWNLOAD_FAILURE;
269 return S_OK;
272 static HRESULT HttpProtocol_end_request(Protocol *protocol)
274 BOOL res;
276 res = HttpEndRequestW(protocol->request, NULL, 0, 0);
277 if(!res && GetLastError() != ERROR_IO_PENDING) {
278 FIXME("HttpEndRequest failed: %u\n", GetLastError());
279 return E_FAIL;
282 return S_OK;
285 static HRESULT HttpProtocol_start_downloading(Protocol *prot)
287 HttpProtocol *This = ASYNCPROTOCOL_THIS(prot);
288 LPWSTR content_type, content_length, ranges;
289 DWORD len = sizeof(DWORD);
290 DWORD status_code;
291 BOOL res;
292 HRESULT hres;
294 static const WCHAR wszDefaultContentType[] =
295 {'t','e','x','t','/','h','t','m','l',0};
297 if(!This->http_negotiate) {
298 WARN("Expected IHttpNegotiate pointer to be non-NULL\n");
299 return S_OK;
302 res = HttpQueryInfoW(This->base.request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
303 &status_code, &len, NULL);
304 if(res) {
305 LPWSTR response_headers = query_http_info(This, HTTP_QUERY_RAW_HEADERS_CRLF);
306 if(response_headers) {
307 hres = IHttpNegotiate_OnResponse(This->http_negotiate, status_code, response_headers,
308 NULL, NULL);
309 heap_free(response_headers);
310 if (hres != S_OK) {
311 WARN("IHttpNegotiate_OnResponse failed: %08x\n", hres);
312 return S_OK;
315 }else {
316 WARN("HttpQueryInfo failed: %d\n", GetLastError());
319 ranges = query_http_info(This, HTTP_QUERY_ACCEPT_RANGES);
320 if(ranges) {
321 IInternetProtocolSink_ReportProgress(This->base.protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
322 heap_free(ranges);
325 content_type = query_http_info(This, HTTP_QUERY_CONTENT_TYPE);
326 if(content_type) {
327 /* remove the charset, if present */
328 LPWSTR p = strchrW(content_type, ';');
329 if (p) *p = '\0';
331 IInternetProtocolSink_ReportProgress(This->base.protocol_sink,
332 (This->base.bindf & BINDF_FROMURLMON)
333 ? BINDSTATUS_MIMETYPEAVAILABLE : BINDSTATUS_RAWMIMETYPE,
334 content_type);
335 heap_free(content_type);
336 }else {
337 WARN("HttpQueryInfo failed: %d\n", GetLastError());
338 IInternetProtocolSink_ReportProgress(This->base.protocol_sink,
339 (This->base.bindf & BINDF_FROMURLMON)
340 ? BINDSTATUS_MIMETYPEAVAILABLE : BINDSTATUS_RAWMIMETYPE,
341 wszDefaultContentType);
344 content_length = query_http_info(This, HTTP_QUERY_CONTENT_LENGTH);
345 if(content_length) {
346 This->base.content_length = atoiW(content_length);
347 heap_free(content_length);
350 return S_OK;
353 static void HttpProtocol_close_connection(Protocol *prot)
355 HttpProtocol *This = ASYNCPROTOCOL_THIS(prot);
357 if(This->http_negotiate) {
358 IHttpNegotiate_Release(This->http_negotiate);
359 This->http_negotiate = 0;
362 if(This->full_header) {
363 if(This->full_header != wszHeaders)
364 heap_free(This->full_header);
365 This->full_header = 0;
369 #undef ASYNCPROTOCOL_THIS
371 static const ProtocolVtbl AsyncProtocolVtbl = {
372 HttpProtocol_open_request,
373 HttpProtocol_end_request,
374 HttpProtocol_start_downloading,
375 HttpProtocol_close_connection
378 #define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, IInternetProtocolEx, iface)
380 static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
382 HttpProtocol *This = PROTOCOL_THIS(iface);
384 *ppv = NULL;
385 if(IsEqualGUID(&IID_IUnknown, riid)) {
386 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
387 *ppv = PROTOCOLEX(This);
388 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
389 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
390 *ppv = PROTOCOLEX(This);
391 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
392 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
393 *ppv = PROTOCOLEX(This);
394 }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
395 TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv);
396 *ppv = PROTOCOLEX(This);
397 }else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
398 TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
399 *ppv = PRIORITY(This);
400 }else if(IsEqualGUID(&IID_IWinInetInfo, riid)) {
401 TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv);
402 *ppv = INETHTTPINFO(This);
403 }else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
404 TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv);
405 *ppv = INETHTTPINFO(This);
408 if(*ppv) {
409 IInternetProtocol_AddRef(iface);
410 return S_OK;
413 WARN("not supported interface %s\n", debugstr_guid(riid));
414 return E_NOINTERFACE;
417 static ULONG WINAPI HttpProtocol_AddRef(IInternetProtocolEx *iface)
419 HttpProtocol *This = PROTOCOL_THIS(iface);
420 LONG ref = InterlockedIncrement(&This->ref);
421 TRACE("(%p) ref=%d\n", This, ref);
422 return ref;
425 static ULONG WINAPI HttpProtocol_Release(IInternetProtocolEx *iface)
427 HttpProtocol *This = PROTOCOL_THIS(iface);
428 LONG ref = InterlockedDecrement(&This->ref);
430 TRACE("(%p) ref=%d\n", This, ref);
432 if(!ref) {
433 protocol_close_connection(&This->base);
434 heap_free(This);
436 URLMON_UnlockModule();
439 return ref;
442 static HRESULT WINAPI HttpProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
443 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
444 DWORD grfPI, HANDLE_PTR dwReserved)
446 HttpProtocol *This = PROTOCOL_THIS(iface);
447 IUri *uri;
448 HRESULT hres;
450 TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
451 pOIBindInfo, grfPI, dwReserved);
453 hres = CreateUri(szUrl, 0, 0, &uri);
454 if(FAILED(hres))
455 return hres;
457 hres = IInternetProtocolEx_StartEx(PROTOCOLEX(This), uri, pOIProtSink, pOIBindInfo,
458 grfPI, (HANDLE*)dwReserved);
460 IUri_Release(uri);
461 return hres;
464 static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData)
466 HttpProtocol *This = PROTOCOL_THIS(iface);
468 TRACE("(%p)->(%p)\n", This, pProtocolData);
470 return protocol_continue(&This->base, pProtocolData);
473 static HRESULT WINAPI HttpProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason,
474 DWORD dwOptions)
476 HttpProtocol *This = PROTOCOL_THIS(iface);
478 TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
480 return protocol_abort(&This->base, hrReason);
483 static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions)
485 HttpProtocol *This = PROTOCOL_THIS(iface);
487 TRACE("(%p)->(%08x)\n", This, dwOptions);
489 protocol_close_connection(&This->base);
490 return S_OK;
493 static HRESULT WINAPI HttpProtocol_Suspend(IInternetProtocolEx *iface)
495 HttpProtocol *This = PROTOCOL_THIS(iface);
496 FIXME("(%p)\n", This);
497 return E_NOTIMPL;
500 static HRESULT WINAPI HttpProtocol_Resume(IInternetProtocolEx *iface)
502 HttpProtocol *This = PROTOCOL_THIS(iface);
503 FIXME("(%p)\n", This);
504 return E_NOTIMPL;
507 static HRESULT WINAPI HttpProtocol_Read(IInternetProtocolEx *iface, void *pv,
508 ULONG cb, ULONG *pcbRead)
510 HttpProtocol *This = PROTOCOL_THIS(iface);
512 TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
514 return protocol_read(&This->base, pv, cb, pcbRead);
517 static HRESULT WINAPI HttpProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove,
518 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
520 HttpProtocol *This = PROTOCOL_THIS(iface);
521 FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
522 return E_NOTIMPL;
525 static HRESULT WINAPI HttpProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions)
527 HttpProtocol *This = PROTOCOL_THIS(iface);
529 TRACE("(%p)->(%08x)\n", This, dwOptions);
531 return protocol_lock_request(&This->base);
534 static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocolEx *iface)
536 HttpProtocol *This = PROTOCOL_THIS(iface);
538 TRACE("(%p)\n", This);
540 return protocol_unlock_request(&This->base);
543 static HRESULT WINAPI HttpProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri,
544 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
545 DWORD grfPI, HANDLE *dwReserved)
547 HttpProtocol *This = PROTOCOL_THIS(iface);
548 DWORD scheme = 0;
549 HRESULT hres;
551 TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink,
552 pOIBindInfo, grfPI, dwReserved);
554 hres = IUri_GetScheme(pUri, &scheme);
555 if(FAILED(hres))
556 return hres;
557 if(scheme != (This->https ? URL_SCHEME_HTTPS : URL_SCHEME_HTTP))
558 return MK_E_SYNTAX;
560 return protocol_start(&This->base, (IInternetProtocol*)PROTOCOLEX(This), pUri, pOIProtSink, pOIBindInfo);
563 #undef PROTOCOL_THIS
565 static const IInternetProtocolExVtbl HttpProtocolVtbl = {
566 HttpProtocol_QueryInterface,
567 HttpProtocol_AddRef,
568 HttpProtocol_Release,
569 HttpProtocol_Start,
570 HttpProtocol_Continue,
571 HttpProtocol_Abort,
572 HttpProtocol_Terminate,
573 HttpProtocol_Suspend,
574 HttpProtocol_Resume,
575 HttpProtocol_Read,
576 HttpProtocol_Seek,
577 HttpProtocol_LockRequest,
578 HttpProtocol_UnlockRequest,
579 HttpProtocol_StartEx
582 #define PRIORITY_THIS(iface) DEFINE_THIS(HttpProtocol, InternetPriority, iface)
584 static HRESULT WINAPI HttpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
586 HttpProtocol *This = PRIORITY_THIS(iface);
587 return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv);
590 static ULONG WINAPI HttpPriority_AddRef(IInternetPriority *iface)
592 HttpProtocol *This = PRIORITY_THIS(iface);
593 return IInternetProtocolEx_AddRef(PROTOCOLEX(This));
596 static ULONG WINAPI HttpPriority_Release(IInternetPriority *iface)
598 HttpProtocol *This = PRIORITY_THIS(iface);
599 return IInternetProtocolEx_Release(PROTOCOLEX(This));
602 static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
604 HttpProtocol *This = PRIORITY_THIS(iface);
606 TRACE("(%p)->(%d)\n", This, nPriority);
608 This->base.priority = nPriority;
609 return S_OK;
612 static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
614 HttpProtocol *This = PRIORITY_THIS(iface);
616 TRACE("(%p)->(%p)\n", This, pnPriority);
618 *pnPriority = This->base.priority;
619 return S_OK;
622 #undef PRIORITY_THIS
624 static const IInternetPriorityVtbl HttpPriorityVtbl = {
625 HttpPriority_QueryInterface,
626 HttpPriority_AddRef,
627 HttpPriority_Release,
628 HttpPriority_SetPriority,
629 HttpPriority_GetPriority
632 #define INETINFO_THIS(iface) DEFINE_THIS(HttpProtocol, WinInetHttpInfo, iface)
634 static HRESULT WINAPI HttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv)
636 HttpProtocol *This = INETINFO_THIS(iface);
637 return IInternetProtocolEx_QueryInterface(PROTOCOLEX(This), riid, ppv);
640 static ULONG WINAPI HttpInfo_AddRef(IWinInetHttpInfo *iface)
642 HttpProtocol *This = INETINFO_THIS(iface);
643 return IInternetProtocolEx_AddRef(PROTOCOLEX(This));
646 static ULONG WINAPI HttpInfo_Release(IWinInetHttpInfo *iface)
648 HttpProtocol *This = INETINFO_THIS(iface);
649 return IInternetProtocolEx_Release(PROTOCOLEX(This));
652 static HRESULT WINAPI HttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption,
653 void *pBuffer, DWORD *pcbBuffer)
655 HttpProtocol *This = INETINFO_THIS(iface);
656 FIXME("(%p)->(%x %p %p)\n", This, dwOption, pBuffer, pcbBuffer);
657 return E_NOTIMPL;
660 static HRESULT WINAPI HttpInfo_QueryInfo(IWinInetHttpInfo *iface, DWORD dwOption,
661 void *pBuffer, DWORD *pcbBuffer, DWORD *pdwFlags, DWORD *pdwReserved)
663 HttpProtocol *This = INETINFO_THIS(iface);
664 FIXME("(%p)->(%x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuffer, pdwFlags, pdwReserved);
665 return E_NOTIMPL;
668 #undef INETINFO_THIS
670 static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
671 HttpInfo_QueryInterface,
672 HttpInfo_AddRef,
673 HttpInfo_Release,
674 HttpInfo_QueryOption,
675 HttpInfo_QueryInfo
678 static HRESULT create_http_protocol(BOOL https, void **ppobj)
680 HttpProtocol *ret;
682 ret = heap_alloc_zero(sizeof(HttpProtocol));
683 if(!ret)
684 return E_OUTOFMEMORY;
686 ret->base.vtbl = &AsyncProtocolVtbl;
687 ret->lpIInternetProtocolExVtbl = &HttpProtocolVtbl;
688 ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
689 ret->lpWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl;
691 ret->https = https;
692 ret->ref = 1;
694 *ppobj = PROTOCOLEX(ret);
696 URLMON_LockModule();
697 return S_OK;
700 HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
702 TRACE("(%p %p)\n", pUnkOuter, ppobj);
704 return create_http_protocol(FALSE, ppobj);
707 HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
709 TRACE("(%p %p)\n", pUnkOuter, ppobj);
711 return create_http_protocol(TRUE, ppobj);