2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 #define CONTENT_LENGTH "Content-Length"
41 #define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl)
43 #define NSINSTREAM_THIS(iface) DEFINE_THIS(nsProtocolStream, InputStream, iface)
45 static nsresult NSAPI
nsInputStream_QueryInterface(nsIInputStream
*iface
, nsIIDRef riid
,
48 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
52 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
53 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
54 *result
= NSINSTREAM(This
);
55 }else if(IsEqualGUID(&IID_nsIInputStream
, riid
)) {
56 TRACE("(%p)->(IID_nsIInputStream %p)\n", This
, result
);
57 *result
= NSINSTREAM(This
);
61 nsIInputStream_AddRef(NSINSTREAM(This
));
65 WARN("unsupported interface %s\n", debugstr_guid(riid
));
66 return NS_NOINTERFACE
;
69 static nsrefcnt NSAPI
nsInputStream_AddRef(nsIInputStream
*iface
)
71 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
72 LONG ref
= InterlockedIncrement(&This
->ref
);
74 TRACE("(%p) ref=%ld\n", This
, ref
);
80 static nsrefcnt NSAPI
nsInputStream_Release(nsIInputStream
*iface
)
82 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
83 LONG ref
= InterlockedDecrement(&This
->ref
);
85 TRACE("(%p) ref=%ld\n", This
, ref
);
88 HeapFree(GetProcessHeap(), 0, This
);
93 static nsresult NSAPI
nsInputStream_Close(nsIInputStream
*iface
)
95 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
96 FIXME("(%p)\n", This
);
97 return NS_ERROR_NOT_IMPLEMENTED
;
100 static nsresult NSAPI
nsInputStream_Available(nsIInputStream
*iface
, PRUint32
*_retval
)
102 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
103 FIXME("(%p)->(%p)\n", This
, _retval
);
104 return NS_ERROR_NOT_IMPLEMENTED
;
107 static nsresult NSAPI
nsInputStream_Read(nsIInputStream
*iface
, char *aBuf
, PRUint32 aCount
,
110 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
111 FIXME("(%p)->(%p %ld %p)\n", This
, aBuf
, aCount
, _retval
);
112 return NS_ERROR_NOT_IMPLEMENTED
;
115 static nsresult NSAPI
nsInputStream_ReadSegments(nsIInputStream
*iface
,
116 nsresult (WINAPI
*aWriter
)(nsIInputStream
*,void*,const char*,PRUint32
,PRUint32
,PRUint32
*),
117 void *aClousure
, PRUint32 aCount
, PRUint32
*_retval
)
119 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
120 PRUint32 written
= 0;
123 FIXME("(%p)->(%p %p %ld %p)\n", This
, aWriter
, aClousure
, aCount
, _retval
);
128 if(This
->buf_size
> aCount
)
129 FIXME("buf_size > aCount\n");
131 nsres
= aWriter(NSINSTREAM(This
), aClousure
, This
->buf
, 0, This
->buf_size
, &written
);
133 FIXME("aWritter failed: %08lx\n", nsres
);
134 if(written
!= This
->buf_size
)
135 FIXME("written != buf_size\n");
137 This
->buf_size
-= written
;
142 static nsresult NSAPI
nsInputStream_IsNonBlocking(nsIInputStream
*iface
, PRBool
*_retval
)
144 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
145 FIXME("(%p)->(%p)\n", This
, _retval
);
146 return NS_ERROR_NOT_IMPLEMENTED
;
149 #undef NSINSTREAM_THIS
151 static const nsIInputStreamVtbl nsInputStreamVtbl
= {
152 nsInputStream_QueryInterface
,
153 nsInputStream_AddRef
,
154 nsInputStream_Release
,
156 nsInputStream_Available
,
158 nsInputStream_ReadSegments
,
159 nsInputStream_IsNonBlocking
162 static nsProtocolStream
*create_nsprotocol_stream(IStream
*stream
)
164 nsProtocolStream
*ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(nsProtocolStream
));
166 ret
->lpInputStreamVtbl
= &nsInputStreamVtbl
;
173 #define STATUSCLB_THIS(iface) DEFINE_THIS(BSCallback, BindStatusCallback, iface)
175 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
176 REFIID riid
, void **ppv
)
178 BSCallback
*This
= STATUSCLB_THIS(iface
);
181 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
182 TRACE("(%p)->(IID_IUnknown, %p)\n", This
, ppv
);
183 *ppv
= STATUSCLB(This
);
184 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
185 TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This
, ppv
);
186 *ppv
= STATUSCLB(This
);
187 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
188 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
189 *ppv
= SERVPROV(This
);
190 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
191 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
192 *ppv
= HTTPNEG(This
);
193 }else if(IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
194 TRACE("(%p)->(IID_IHttpNegotiate2 %p)\n", This
, ppv
);
195 *ppv
= HTTPNEG(This
);
196 }else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
197 TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This
, ppv
);
198 *ppv
= BINDINFO(This
);
202 IBindStatusCallback_AddRef(STATUSCLB(This
));
206 TRACE("Unsupported riid = %s\n", debugstr_guid(riid
));
207 return E_NOINTERFACE
;
210 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
212 BSCallback
*This
= STATUSCLB_THIS(iface
);
213 LONG ref
= InterlockedIncrement(&This
->ref
);
215 TRACE("(%p) ref = %ld\n", This
, ref
);
220 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
222 BSCallback
*This
= STATUSCLB_THIS(iface
);
223 LONG ref
= InterlockedDecrement(&This
->ref
);
225 TRACE("(%p) ref = %ld\n", This
, ref
);
229 GlobalFree(This
->post_data
);
231 nsIChannel_Release(NSCHANNEL(This
->nschannel
));
233 nsIStreamListener_Release(This
->nslistener
);
235 nsISupports_Release(This
->nscontext
);
237 nsIInputStream_Release(NSINSTREAM(This
->nsstream
));
238 HeapFree(GetProcessHeap(), 0, This
->headers
);
239 HeapFree(GetProcessHeap(), 0, This
);
245 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
246 DWORD dwReserved
, IBinding
*pbind
)
248 BSCallback
*This
= STATUSCLB_THIS(iface
);
249 FIXME("(%p)->(%ld %p)\n", This
, dwReserved
, pbind
);
253 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
255 BSCallback
*This
= STATUSCLB_THIS(iface
);
256 FIXME("(%p)->(%p)\n", This
, pnPriority
);
260 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
, DWORD reserved
)
262 BSCallback
*This
= STATUSCLB_THIS(iface
);
263 FIXME("(%p)->(%ld)\n", This
, reserved
);
267 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
268 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
270 BSCallback
*This
= STATUSCLB_THIS(iface
);
272 TRACE("%p)->(%lu %lu %lu %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
273 debugstr_w(szStatusText
));
275 switch(ulStatusCode
) {
276 case BINDSTATUS_MIMETYPEAVAILABLE
: {
281 HeapFree(GetProcessHeap(), 0, This
->nschannel
->content
);
283 len
= WideCharToMultiByte(CP_ACP
, 0, szStatusText
, -1, NULL
, 0, NULL
, NULL
);
284 This
->nschannel
->content
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
285 WideCharToMultiByte(CP_ACP
, 0, szStatusText
, -1, This
->nschannel
->content
, -1, NULL
, NULL
);
292 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
293 HRESULT hresult
, LPCWSTR szError
)
295 BSCallback
*This
= STATUSCLB_THIS(iface
);
296 FIXME("(%p)->(%08lx %s)\n", This
, hresult
, debugstr_w(szError
));
300 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
301 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
303 BSCallback
*This
= STATUSCLB_THIS(iface
);
306 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
308 *grfBINDF
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
310 size
= pbindinfo
->cbSize
;
311 memset(pbindinfo
, 0, size
);
312 pbindinfo
->cbSize
= size
;
314 pbindinfo
->cbStgmedData
= This
->post_data_len
;
315 pbindinfo
->dwCodePage
= CP_UTF8
;
316 pbindinfo
->dwOptions
= 0x00020000;
318 if(This
->post_data
) {
319 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
321 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
322 pbindinfo
->stgmedData
.u
.hGlobal
= This
->post_data
;
323 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)STATUSCLB(This
);
324 IBindStatusCallback_AddRef(STATUSCLB(This
));
330 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
331 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
333 BSCallback
*This
= STATUSCLB_THIS(iface
);
337 TRACE("(%p)->(%08lx %ld %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
339 if(This
->nslistener
) {
340 if(!This
->nsstream
) {
341 This
->nsstream
= create_nsprotocol_stream(pstgmed
->u
.pstm
);
343 nsres
= nsIStreamListener_OnStartRequest(This
->nslistener
,
344 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
);
346 FIXME("OnStartRequest failed: %08lx\n", nsres
);
350 hres
= IStream_Read(pstgmed
->u
.pstm
, This
->nsstream
->buf
, sizeof(This
->nsstream
->buf
),
351 &This
->nsstream
->buf_size
);
352 if(This
->nsstream
->buf_size
) {
353 nsres
= nsIStreamListener_OnDataAvailable(This
->nslistener
,
354 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
,
355 NSINSTREAM(This
->nsstream
), 0 /* FIXME */, dwSize
);
357 FIXME("OnDataAvailable failed: %08lx\n", nsres
);
359 if(This
->nsstream
->buf_size
)
360 FIXME("buffer is not empty!\n");
362 }while(hres
== S_OK
);
368 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
369 REFIID riid
, IUnknown
*punk
)
371 BSCallback
*This
= STATUSCLB_THIS(iface
);
372 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
376 #undef STATUSCLB_THIS
378 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
379 BindStatusCallback_QueryInterface
,
380 BindStatusCallback_AddRef
,
381 BindStatusCallback_Release
,
382 BindStatusCallback_OnStartBinding
,
383 BindStatusCallback_GetPriority
,
384 BindStatusCallback_OnLowResource
,
385 BindStatusCallback_OnProgress
,
386 BindStatusCallback_OnStopBinding
,
387 BindStatusCallback_GetBindInfo
,
388 BindStatusCallback_OnDataAvailable
,
389 BindStatusCallback_OnObjectAvailable
392 #define HTTPNEG_THIS(iface) DEFINE_THIS(BSCallback, HttpNegotiate2, iface)
394 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
,
395 REFIID riid
, void **ppv
)
397 BSCallback
*This
= HTTPNEG_THIS(iface
);
398 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
401 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
403 BSCallback
*This
= HTTPNEG_THIS(iface
);
404 return IBindStatusCallback_AddRef(STATUSCLB(This
));
407 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
409 BSCallback
*This
= HTTPNEG_THIS(iface
);
410 return IBindStatusCallback_Release(STATUSCLB(This
));
413 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
,
414 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
416 BSCallback
*This
= HTTPNEG_THIS(iface
);
419 TRACE("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
420 dwReserved
, pszAdditionalHeaders
);
423 *pszAdditionalHeaders
= NULL
;
427 size
= (strlenW(This
->headers
)+1)*sizeof(WCHAR
);
428 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
429 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
434 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
435 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
437 BSCallback
*This
= HTTPNEG_THIS(iface
);
438 FIXME("(%p)->(%ld %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
439 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
443 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
444 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
446 BSCallback
*This
= HTTPNEG_THIS(iface
);
447 FIXME("(%p)->(%p %p %ld)\n", This
, pbSecurityId
, pcbSecurityId
, dwReserved
);
453 static const IHttpNegotiate2Vtbl HttpNegotiate2Vtbl
= {
454 HttpNegotiate_QueryInterface
,
455 HttpNegotiate_AddRef
,
456 HttpNegotiate_Release
,
457 HttpNegotiate_BeginningTransaction
,
458 HttpNegotiate_OnResponse
,
459 HttpNegotiate_GetRootSecurityId
462 #define BINDINFO_THIS(iface) DEFINE_THIS(BSCallback, InternetBindInfo, iface)
464 static HRESULT WINAPI
InternetBindInfo_QueryInterface(IInternetBindInfo
*iface
,
465 REFIID riid
, void **ppv
)
467 BSCallback
*This
= BINDINFO_THIS(iface
);
468 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
471 static ULONG WINAPI
InternetBindInfo_AddRef(IInternetBindInfo
*iface
)
473 BSCallback
*This
= BINDINFO_THIS(iface
);
474 return IBindStatusCallback_AddRef(STATUSCLB(This
));
477 static ULONG WINAPI
InternetBindInfo_Release(IInternetBindInfo
*iface
)
479 BSCallback
*This
= BINDINFO_THIS(iface
);
480 return IBindStatusCallback_Release(STATUSCLB(This
));
483 static HRESULT WINAPI
InternetBindInfo_GetBindInfo(IInternetBindInfo
*iface
,
484 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
486 BSCallback
*This
= BINDINFO_THIS(iface
);
487 FIXME("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
491 static HRESULT WINAPI
InternetBindInfo_GetBindString(IInternetBindInfo
*iface
,
492 ULONG ulStringType
, LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
494 BSCallback
*This
= BINDINFO_THIS(iface
);
495 FIXME("(%p)->(%lu %p %lu %p)\n", This
, ulStringType
, ppwzStr
, cEl
, pcElFetched
);
501 static const IInternetBindInfoVtbl InternetBindInfoVtbl
= {
502 InternetBindInfo_QueryInterface
,
503 InternetBindInfo_AddRef
,
504 InternetBindInfo_Release
,
505 InternetBindInfo_GetBindInfo
,
506 InternetBindInfo_GetBindString
509 #define SERVPROV_THIS(iface) DEFINE_THIS(BSCallback, ServiceProvider, iface)
511 static HRESULT WINAPI
BSCServiceProvider_QueryInterface(IServiceProvider
*iface
,
512 REFIID riid
, void **ppv
)
514 BSCallback
*This
= SERVPROV_THIS(iface
);
515 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
518 static ULONG WINAPI
BSCServiceProvider_AddRef(IServiceProvider
*iface
)
520 BSCallback
*This
= SERVPROV_THIS(iface
);
521 return IBindStatusCallback_AddRef(STATUSCLB(This
));
524 static ULONG WINAPI
BSCServiceProvider_Release(IServiceProvider
*iface
)
526 BSCallback
*This
= SERVPROV_THIS(iface
);
527 return IBindStatusCallback_Release(STATUSCLB(This
));
530 static HRESULT WINAPI
BSCServiceProvider_QueryService(IServiceProvider
*iface
,
531 REFGUID guidService
, REFIID riid
, void **ppv
)
533 BSCallback
*This
= SERVPROV_THIS(iface
);
534 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
540 static const IServiceProviderVtbl ServiceProviderVtbl
= {
541 BSCServiceProvider_QueryInterface
,
542 BSCServiceProvider_AddRef
,
543 BSCServiceProvider_Release
,
544 BSCServiceProvider_QueryService
547 BSCallback
*create_bscallback(HTMLDocument
*doc
, LPCOLESTR url
)
549 BSCallback
*ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(BSCallback
));
551 ret
->lpBindStatusCallbackVtbl
= &BindStatusCallbackVtbl
;
552 ret
->lpServiceProviderVtbl
= &ServiceProviderVtbl
;
553 ret
->lpHttpNegotiate2Vtbl
= &HttpNegotiate2Vtbl
;
554 ret
->lpInternetBindInfoVtbl
= &InternetBindInfoVtbl
;
556 ret
->post_data
= NULL
;
558 ret
->post_data_len
= 0;
559 ret
->nschannel
= NULL
;
560 ret
->nslistener
= NULL
;
561 ret
->nscontext
= NULL
;
562 ret
->nsstream
= NULL
;
567 static void parse_post_data(nsIInputStream
*post_data_stream
, LPWSTR
*headers_ret
,
568 HGLOBAL
*post_data_ret
, ULONG
*post_data_len_ret
)
570 PRUint32 post_data_len
= 0, available
= 0;
571 HGLOBAL post_data
= NULL
;
572 LPWSTR headers
= NULL
;
573 DWORD headers_len
= 0, len
;
574 const char *ptr
, *ptr2
, *post_data_end
;
576 nsIInputStream_Available(post_data_stream
, &available
);
577 post_data
= GlobalAlloc(0, available
+1);
578 nsIInputStream_Read(post_data_stream
, post_data
, available
, &post_data_len
);
580 TRACE("post_data = %s\n", debugstr_an(post_data
, post_data_len
));
582 ptr
= ptr2
= post_data
;
583 post_data_end
= (const char*)post_data
+post_data_len
;
585 while(ptr
< post_data_end
&& (*ptr
!= '\r' || ptr
[1] != '\n')) {
586 while(ptr
< post_data_end
&& (*ptr
!= '\r' || ptr
[1] != '\n'))
596 if(ptr
-ptr2
>= sizeof(CONTENT_LENGTH
)
597 && CompareStringA(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
,
598 CONTENT_LENGTH
, sizeof(CONTENT_LENGTH
)-1,
599 ptr2
, sizeof(CONTENT_LENGTH
)-1) == CSTR_EQUAL
) {
604 len
= MultiByteToWideChar(CP_ACP
, 0, ptr2
, ptr
-ptr2
, NULL
, 0);
607 headers
= HeapReAlloc(GetProcessHeap(), 0, headers
,
608 (headers_len
+len
+1)*sizeof(WCHAR
));
610 headers
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
612 len
= MultiByteToWideChar(CP_ACP
, 0, ptr2
, ptr
-ptr2
, headers
+headers_len
, -1);
618 headers
[headers_len
] = 0;
619 *headers_ret
= headers
;
621 if(ptr
>= post_data_end
-2) {
622 GlobalFree(post_data
);
629 post_data_len
-= ptr
-(const char*)post_data
;
630 memmove(post_data
, ptr
, post_data_len
);
631 post_data
= GlobalReAlloc(post_data
, post_data_len
+1, 0);
634 *post_data_ret
= post_data
;
635 *post_data_len_ret
= post_data_len
;
638 void hlink_frame_navigate(HTMLDocument
*doc
, IHlinkFrame
*hlink_frame
,
639 LPCWSTR uri
, nsIInputStream
*post_data_stream
, DWORD hlnf
)
641 BSCallback
*callback
;
646 callback
= create_bscallback(doc
, uri
);
648 if(post_data_stream
) {
649 parse_post_data(post_data_stream
, &callback
->headers
, &callback
->post_data
,
650 &callback
->post_data_len
);
651 TRACE("headers = %s post_data = %s\n", debugstr_w(callback
->headers
),
652 debugstr_an(callback
->post_data
, callback
->post_data_len
));
655 CreateAsyncBindCtx(0, STATUSCLB(callback
), NULL
, &bindctx
);
657 hlink
= Hlink_Create();
659 CreateURLMoniker(NULL
, uri
, &mon
);
660 IHlink_SetMonikerReference(hlink
, 0, mon
, NULL
);
662 if(hlnf
& HLNF_OPENINNEWWINDOW
) {
663 static const WCHAR wszBlank
[] = {'_','b','l','a','n','k',0};
664 IHlink_SetTargetFrameName(hlink
, wszBlank
); /* FIXME */
667 IHlinkFrame_Navigate(hlink_frame
, hlnf
, bindctx
, STATUSCLB(callback
), hlink
);
669 IBindCtx_Release(bindctx
);
670 IBindStatusCallback_Release(STATUSCLB(callback
));
671 IMoniker_Release(mon
);
675 HRESULT
start_binding(BSCallback
*bscallback
, IMoniker
*mon
)
681 hres
= CreateAsyncBindCtx(0, STATUSCLB(bscallback
), NULL
, &bctx
);
683 WARN("CreateAsyncBindCtx failed: %08lx\n", hres
);
687 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&str
);
688 IBindCtx_Release(bctx
);
690 WARN("BindToStorage failed: %08lx\n", hres
);
695 IStream_Release(str
);