2 * Copyright 2006-2010 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
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
42 #define NS_IOSERVICE_CLASSNAME "nsIOService"
43 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
45 static const IID NS_IOSERVICE_CID
=
46 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
47 static const IID IID_nsWineURI
=
48 {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
50 static nsIIOService
*nsio
= NULL
;
52 static const char *request_method_strings
[] = {"GET", "PUT", "POST"};
55 nsIFileURL nsIFileURL_iface
; /* For non-file URL objects, it's just nsIURL */
56 nsIStandardURL nsIStandardURL_iface
;
60 NSContainer
*container
;
61 windowref_t
*window_ref
;
62 nsChannelBSC
*channel_bsc
;
64 IUriBuilder
*uri_builder
;
71 static BOOL
ensure_uri(nsWineURI
*This
)
75 assert(This
->uri
|| This
->uri_builder
);
78 hres
= IUriBuilder_CreateUriSimple(This
->uri_builder
, 0, 0, &This
->uri
);
80 WARN("CreateUriSimple failed: %08x\n", hres
);
88 IUri
*nsuri_get_uri(nsWineURI
*nsuri
)
90 if(!ensure_uri(nsuri
))
93 IUri_AddRef(nsuri
->uri
);
97 IUri
*get_uri_nofrag(IUri
*uri
)
99 IUriBuilder
*uri_builder
;
104 hres
= IUri_HasProperty(uri
, Uri_PROPERTY_FRAGMENT
, &b
);
105 if(SUCCEEDED(hres
) && !b
) {
110 hres
= CreateIUriBuilder(uri
, 0, 0, &uri_builder
);
114 hres
= IUriBuilder_RemoveProperties(uri_builder
, Uri_HAS_FRAGMENT
);
116 hres
= IUriBuilder_CreateUriSimple(uri_builder
, 0, 0, &ret
);
117 IUriBuilder_Release(uri_builder
);
124 static BOOL
compare_ignoring_frag(IUri
*uri1
, IUri
*uri2
)
126 IUri
*uri_nofrag1
, *uri_nofrag2
;
129 uri_nofrag1
= get_uri_nofrag(uri1
);
133 uri_nofrag2
= get_uri_nofrag(uri2
);
135 IUri_IsEqual(uri_nofrag1
, uri_nofrag2
, &ret
);
136 IUri_Release(uri_nofrag2
);
139 IUri_Release(uri_nofrag1
);
143 static HRESULT
combine_url(IUri
*base_uri
, const WCHAR
*rel_url
, IUri
**ret
)
148 uri_nofrag
= get_uri_nofrag(base_uri
);
152 hres
= CoInternetCombineUrlEx(uri_nofrag
, rel_url
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
154 IUri_Release(uri_nofrag
);
156 WARN("CoInternetCombineUrlEx failed: %08x\n", hres
);
160 static nsresult
create_nsuri(IUri
*,HTMLOuterWindow
*,NSContainer
*,const char*,nsWineURI
**);
162 static const char *debugstr_nsacstr(const nsACString
*nsstr
)
166 nsACString_GetData(nsstr
, &data
);
167 return debugstr_a(data
);
170 static nsresult
return_wstr_nsacstr(nsACString
*ret_str
, const WCHAR
*str
, int len
)
175 TRACE("returning %s\n", debugstr_wn(str
, len
));
178 nsACString_SetData(ret_str
, "");
182 lena
= WideCharToMultiByte(CP_UTF8
, 0, str
, len
, NULL
, 0, NULL
, NULL
);
183 stra
= heap_alloc(lena
+1);
185 return NS_ERROR_OUT_OF_MEMORY
;
187 WideCharToMultiByte(CP_UTF8
, 0, str
, len
, stra
, lena
, NULL
, NULL
);
190 nsACString_SetData(ret_str
, stra
);
195 HRESULT
nsuri_to_url(LPCWSTR nsuri
, BOOL ret_empty
, BSTR
*ret
)
197 const WCHAR
*ptr
= nsuri
;
199 static const WCHAR wine_prefixW
[] = {'w','i','n','e',':'};
201 if(!strncmpW(nsuri
, wine_prefixW
, sizeof(wine_prefixW
)/sizeof(WCHAR
)))
202 ptr
+= sizeof(wine_prefixW
)/sizeof(WCHAR
);
204 if(*ptr
|| ret_empty
) {
205 *ret
= SysAllocString(ptr
);
207 return E_OUTOFMEMORY
;
212 TRACE("%s -> %s\n", debugstr_w(nsuri
), debugstr_w(*ret
));
216 static BOOL
exec_shldocvw_67(HTMLDocumentObj
*doc
, BSTR url
)
218 IOleCommandTarget
*cmdtrg
= NULL
;
221 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
222 if(SUCCEEDED(hres
)) {
223 VARIANT varUrl
, varRes
;
225 V_VT(&varUrl
) = VT_BSTR
;
226 V_BSTR(&varUrl
) = url
;
227 V_VT(&varRes
) = VT_BOOL
;
229 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
231 IOleCommandTarget_Release(cmdtrg
);
233 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
234 TRACE("got VARIANT_FALSE, do not load\n");
242 static nsresult
before_async_open(nsChannel
*channel
, NSContainer
*container
, BOOL
*cancel
)
244 HTMLDocumentObj
*doc
= container
->doc
;
253 hres
= IUri_GetDisplayUri(channel
->uri
->uri
, &display_uri
);
255 return NS_ERROR_FAILURE
;
257 if(!exec_shldocvw_67(doc
, display_uri
)) {
258 SysFreeString(display_uri
);
263 hres
= hlink_frame_navigate(&doc
->basedoc
, display_uri
, channel
, 0, cancel
);
264 SysFreeString(display_uri
);
270 HRESULT
load_nsuri(HTMLOuterWindow
*window
, nsWineURI
*uri
, nsIInputStream
*post_stream
,
271 nsChannelBSC
*channelbsc
, DWORD flags
)
273 nsIDocShellLoadInfo
*load_info
= NULL
;
274 nsIWebNavigation
*web_navigation
;
275 nsIDocShell
*doc_shell
;
276 HTMLDocumentNode
*doc
;
279 nsres
= get_nsinterface((nsISupports
*)window
->nswindow
, &IID_nsIWebNavigation
, (void**)&web_navigation
);
280 if(NS_FAILED(nsres
)) {
281 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
285 nsres
= nsIWebNavigation_QueryInterface(web_navigation
, &IID_nsIDocShell
, (void**)&doc_shell
);
286 nsIWebNavigation_Release(web_navigation
);
287 if(NS_FAILED(nsres
)) {
288 ERR("Could not get nsIDocShell: %08x\n", nsres
);
293 nsres
= nsIDocShell_CreateLoadInfo(doc_shell
, &load_info
);
294 if(NS_FAILED(nsres
)) {
295 nsIDocShell_Release(doc_shell
);
299 nsres
= nsIDocShellLoadInfo_SetPostDataStream(load_info
, post_stream
);
300 assert(nsres
== NS_OK
);
303 uri
->channel_bsc
= channelbsc
;
304 doc
= window
->base
.inner_window
->doc
;
305 doc
->skip_mutation_notif
= TRUE
;
306 nsres
= nsIDocShell_LoadURI(doc_shell
, (nsIURI
*)&uri
->nsIFileURL_iface
, load_info
, flags
, FALSE
);
307 if(doc
== window
->base
.inner_window
->doc
)
308 doc
->skip_mutation_notif
= FALSE
;
309 uri
->channel_bsc
= NULL
;
310 nsIDocShell_Release(doc_shell
);
312 nsIDocShellLoadInfo_Release(load_info
);
313 if(NS_FAILED(nsres
)) {
314 WARN("LoadURI failed: %08x\n", nsres
);
321 static void set_uri_nscontainer(nsWineURI
*This
, NSContainer
*nscontainer
)
323 if(This
->container
) {
324 if(This
->container
== nscontainer
)
326 TRACE("Changing %p -> %p\n", This
->container
, nscontainer
);
327 nsIWebBrowserChrome_Release(&This
->container
->nsIWebBrowserChrome_iface
);
331 nsIWebBrowserChrome_AddRef(&nscontainer
->nsIWebBrowserChrome_iface
);
332 This
->container
= nscontainer
;
335 static void set_uri_window(nsWineURI
*This
, HTMLOuterWindow
*window
)
337 if(This
->window_ref
) {
338 if(This
->window_ref
->window
== window
)
340 TRACE("Changing %p -> %p\n", This
->window_ref
->window
, window
);
341 windowref_release(This
->window_ref
);
345 windowref_addref(window
->window_ref
);
346 This
->window_ref
= window
->window_ref
;
349 set_uri_nscontainer(This
, window
->doc_obj
->nscontainer
);
351 This
->window_ref
= NULL
;
355 static inline BOOL
is_http_channel(nsChannel
*This
)
357 return This
->uri
->scheme
== URL_SCHEME_HTTP
|| This
->uri
->scheme
== URL_SCHEME_HTTPS
;
360 static http_header_t
*find_http_header(struct list
*headers
, const WCHAR
*name
, int len
)
364 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
365 if(!strncmpiW(iter
->header
, name
, len
) && !iter
->header
[len
])
372 static nsresult
get_channel_http_header(struct list
*headers
, const nsACString
*header_name_str
,
375 const char *header_namea
;
376 http_header_t
*header
;
380 nsACString_GetData(header_name_str
, &header_namea
);
381 header_name
= heap_strdupAtoW(header_namea
);
383 return NS_ERROR_UNEXPECTED
;
385 header
= find_http_header(headers
, header_name
, strlenW(header_name
));
386 heap_free(header_name
);
388 return NS_ERROR_NOT_AVAILABLE
;
390 data
= heap_strdupWtoA(header
->data
);
392 return NS_ERROR_UNEXPECTED
;
394 TRACE("%s -> %s\n", debugstr_a(header_namea
), debugstr_a(data
));
395 nsACString_SetData(_retval
, data
);
400 HRESULT
set_http_header(struct list
*headers
, const WCHAR
*name
, int name_len
,
401 const WCHAR
*value
, int value_len
)
403 http_header_t
*header
;
405 TRACE("%s: %s\n", debugstr_wn(name
, name_len
), debugstr_wn(value
, value_len
));
407 header
= find_http_header(headers
, name
, name_len
);
411 new_data
= heap_strndupW(value
, value_len
);
413 return E_OUTOFMEMORY
;
415 heap_free(header
->data
);
416 header
->data
= new_data
;
418 header
= heap_alloc(sizeof(http_header_t
));
420 return E_OUTOFMEMORY
;
422 header
->header
= heap_strndupW(name
, name_len
);
423 header
->data
= heap_strndupW(value
, value_len
);
424 if(!header
->header
|| !header
->data
) {
425 heap_free(header
->header
);
426 heap_free(header
->data
);
428 return E_OUTOFMEMORY
;
431 list_add_tail(headers
, &header
->entry
);
437 static nsresult
set_channel_http_header(struct list
*headers
, const nsACString
*name_str
,
438 const nsACString
*value_str
)
440 const char *namea
, *valuea
;
444 nsACString_GetData(name_str
, &namea
);
445 name
= heap_strdupAtoW(namea
);
447 return NS_ERROR_UNEXPECTED
;
449 nsACString_GetData(value_str
, &valuea
);
450 value
= heap_strdupAtoW(valuea
);
453 return NS_ERROR_UNEXPECTED
;
456 hres
= set_http_header(headers
, name
, strlenW(name
), value
, strlenW(value
));
460 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_UNEXPECTED
;
463 static nsresult
visit_http_headers(struct list
*headers
, nsIHttpHeaderVisitor
*visitor
)
465 nsACString header_str
, value_str
;
466 char *header
, *value
;
470 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
471 header
= heap_strdupWtoA(iter
->header
);
473 return NS_ERROR_OUT_OF_MEMORY
;
475 value
= heap_strdupWtoA(iter
->data
);
478 return NS_ERROR_OUT_OF_MEMORY
;
481 nsACString_InitDepend(&header_str
, header
);
482 nsACString_InitDepend(&value_str
, value
);
483 nsres
= nsIHttpHeaderVisitor_VisitHeader(visitor
, &header_str
, &value_str
);
484 nsACString_Finish(&header_str
);
485 nsACString_Finish(&value_str
);
495 static void free_http_headers(struct list
*list
)
497 http_header_t
*iter
, *iter_next
;
499 LIST_FOR_EACH_ENTRY_SAFE(iter
, iter_next
, list
, http_header_t
, entry
) {
500 list_remove(&iter
->entry
);
501 heap_free(iter
->header
);
502 heap_free(iter
->data
);
507 static inline nsChannel
*impl_from_nsIHttpChannel(nsIHttpChannel
*iface
)
509 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannel_iface
);
512 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, void **result
)
514 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
516 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
517 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
518 *result
= &This
->nsIHttpChannel_iface
;
519 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
520 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
521 *result
= &This
->nsIHttpChannel_iface
;
522 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
523 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
524 *result
= &This
->nsIHttpChannel_iface
;
525 }else if(IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
526 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
527 *result
= is_http_channel(This
) ? &This
->nsIHttpChannel_iface
: NULL
;
528 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
529 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
530 *result
= &This
->nsIUploadChannel_iface
;
531 }else if(IsEqualGUID(&IID_nsIHttpChannelInternal
, riid
)) {
532 TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This
, result
);
533 *result
= is_http_channel(This
) ? &This
->nsIHttpChannelInternal_iface
: NULL
;
535 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
540 nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
544 return NS_NOINTERFACE
;
547 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
549 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
550 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
552 TRACE("(%p) ref=%d\n", This
, ref
);
557 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
559 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
560 LONG ref
= InterlockedDecrement(&This
->ref
);
563 nsIFileURL_Release(&This
->uri
->nsIFileURL_iface
);
565 nsISupports_Release(This
->owner
);
566 if(This
->post_data_stream
)
567 nsIInputStream_Release(This
->post_data_stream
);
569 nsILoadGroup_Release(This
->load_group
);
570 if(This
->notif_callback
)
571 nsIInterfaceRequestor_Release(This
->notif_callback
);
572 if(This
->original_uri
)
573 nsIURI_Release(This
->original_uri
);
575 nsIURI_Release(This
->referrer
);
577 free_http_headers(&This
->response_headers
);
578 free_http_headers(&This
->request_headers
);
580 heap_free(This
->content_type
);
581 heap_free(This
->charset
);
588 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
590 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
592 TRACE("(%p)->(%p)\n", This
, aName
);
594 return nsIFileURL_GetSpec(&This
->uri
->nsIFileURL_iface
, aName
);
597 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
599 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
601 FIXME("(%p)->(%p)\n", This
, _retval
);
603 return NS_ERROR_NOT_IMPLEMENTED
;
606 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
608 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
610 WARN("(%p)->(%p) returning NS_OK\n", This
, aStatus
);
612 return *aStatus
= NS_OK
;
615 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
617 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
619 TRACE("(%p)->(%08x)\n", This
, aStatus
);
621 if(This
->binding
&& This
->binding
->bsc
.binding
)
622 IBinding_Abort(This
->binding
->bsc
.binding
);
624 WARN("No binding to cancel\n");
628 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
630 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
632 FIXME("(%p)\n", This
);
634 return NS_ERROR_NOT_IMPLEMENTED
;
637 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
639 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
641 FIXME("(%p)\n", This
);
643 return NS_ERROR_NOT_IMPLEMENTED
;
646 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
648 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
650 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
653 nsILoadGroup_AddRef(This
->load_group
);
655 *aLoadGroup
= This
->load_group
;
659 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
661 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
663 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
666 nsILoadGroup_Release(This
->load_group
);
668 nsILoadGroup_AddRef(aLoadGroup
);
669 This
->load_group
= aLoadGroup
;
674 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
676 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
678 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
680 *aLoadFlags
= This
->load_flags
;
684 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
686 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
688 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
690 This
->load_flags
= aLoadFlags
;
694 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
696 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
698 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
700 if(This
->original_uri
)
701 nsIURI_AddRef(This
->original_uri
);
703 *aOriginalURI
= This
->original_uri
;
707 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
709 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
711 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
713 if(This
->original_uri
)
714 nsIURI_Release(This
->original_uri
);
716 nsIURI_AddRef(aOriginalURI
);
717 This
->original_uri
= aOriginalURI
;
721 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
723 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
725 TRACE("(%p)->(%p)\n", This
, aURI
);
727 nsIFileURL_AddRef(&This
->uri
->nsIFileURL_iface
);
728 *aURI
= (nsIURI
*)This
->uri
;
733 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
735 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
737 TRACE("(%p)->(%p)\n", This
, aOwner
);
740 nsISupports_AddRef(This
->owner
);
741 *aOwner
= This
->owner
;
746 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
748 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
750 TRACE("(%p)->(%p)\n", This
, aOwner
);
753 nsISupports_AddRef(aOwner
);
755 nsISupports_Release(This
->owner
);
756 This
->owner
= aOwner
;
761 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
762 nsIInterfaceRequestor
**aNotificationCallbacks
)
764 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
766 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
768 if(This
->notif_callback
)
769 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
770 *aNotificationCallbacks
= This
->notif_callback
;
775 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
776 nsIInterfaceRequestor
*aNotificationCallbacks
)
778 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
780 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
782 if(This
->notif_callback
)
783 nsIInterfaceRequestor_Release(This
->notif_callback
);
784 if(aNotificationCallbacks
)
785 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
787 This
->notif_callback
= aNotificationCallbacks
;
792 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
794 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
796 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
798 return NS_ERROR_NOT_IMPLEMENTED
;
801 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
803 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
805 TRACE("(%p)->(%p)\n", This
, aContentType
);
807 if(This
->content_type
) {
808 nsACString_SetData(aContentType
, This
->content_type
);
812 if(This
->uri
->is_doc_uri
) {
813 WARN("Document channel with no MIME set. Assuming text/html\n");
814 nsACString_SetData(aContentType
, "text/html");
818 WARN("unknown type\n");
819 return NS_ERROR_FAILURE
;
822 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
823 const nsACString
*aContentType
)
825 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
826 const char *content_type
;
828 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentType
));
830 nsACString_GetData(aContentType
, &content_type
);
831 heap_free(This
->content_type
);
832 This
->content_type
= heap_strdupA(content_type
);
837 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
838 nsACString
*aContentCharset
)
840 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
842 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
845 nsACString_SetData(aContentCharset
, This
->charset
);
849 nsACString_SetData(aContentCharset
, "");
853 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
854 const nsACString
*aContentCharset
)
856 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
860 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentCharset
));
862 nsACString_GetData(aContentCharset
, &data
);
863 charset
= heap_strdupA(data
);
865 return NS_ERROR_OUT_OF_MEMORY
;
867 heap_free(This
->charset
);
868 This
->charset
= charset
;
872 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, INT64
*aContentLength
)
874 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
876 FIXME("(%p)->(%p)\n", This
, aContentLength
);
878 return NS_ERROR_NOT_IMPLEMENTED
;
881 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, INT64 aContentLength
)
883 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
885 FIXME("(%p)->(%s)\n", This
, wine_dbgstr_longlong(aContentLength
));
887 return NS_ERROR_NOT_IMPLEMENTED
;
890 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
892 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
894 FIXME("(%p)->(%p)\n", This
, _retval
);
896 return NS_ERROR_NOT_IMPLEMENTED
;
899 static nsresult NSAPI
nsChannel_Open2(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
901 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
903 FIXME("(%p)->(%p)\n", This
, _retval
);
905 return NS_ERROR_NOT_IMPLEMENTED
;
908 static HTMLOuterWindow
*get_window_from_load_group(nsChannel
*This
)
910 HTMLOuterWindow
*window
;
917 nsres
= nsILoadGroup_GetDefaultLoadRequest(This
->load_group
, &req
);
918 if(NS_FAILED(nsres
)) {
919 ERR("GetDefaultLoadRequest failed: %08x\n", nsres
);
926 nsres
= nsIRequest_QueryInterface(req
, &IID_nsIChannel
, (void**)&channel
);
927 nsIRequest_Release(req
);
928 if(NS_FAILED(nsres
)) {
929 WARN("Could not get nsIChannel interface: %08x\n", nsres
);
933 nsres
= nsIChannel_GetURI(channel
, &uri
);
934 nsIChannel_Release(channel
);
935 if(NS_FAILED(nsres
)) {
936 ERR("GetURI failed: %08x\n", nsres
);
940 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
942 if(NS_FAILED(nsres
)) {
943 TRACE("Could not get nsWineURI: %08x\n", nsres
);
947 window
= wine_uri
->window_ref
? wine_uri
->window_ref
->window
: NULL
;
949 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
950 nsIFileURL_Release(&wine_uri
->nsIFileURL_iface
);
955 static HTMLOuterWindow
*get_channel_window(nsChannel
*This
)
957 nsIWebProgress
*web_progress
;
958 nsIDOMWindow
*nswindow
;
959 HTMLOuterWindow
*window
;
962 if(This
->load_group
) {
963 nsIRequestObserver
*req_observer
;
965 nsres
= nsILoadGroup_GetGroupObserver(This
->load_group
, &req_observer
);
966 if(NS_FAILED(nsres
) || !req_observer
) {
967 ERR("GetGroupObserver failed: %08x\n", nsres
);
971 nsres
= nsIRequestObserver_QueryInterface(req_observer
, &IID_nsIWebProgress
, (void**)&web_progress
);
972 nsIRequestObserver_Release(req_observer
);
973 if(NS_FAILED(nsres
)) {
974 ERR("Could not get nsIWebProgress iface: %08x\n", nsres
);
977 }else if(This
->notif_callback
) {
978 nsres
= nsIInterfaceRequestor_GetInterface(This
->notif_callback
, &IID_nsIWebProgress
, (void**)&web_progress
);
979 if(NS_FAILED(nsres
)) {
980 ERR("GetInterface(IID_nsIWebProgress failed: %08x\n", nsres
);
984 ERR("no load group nor notif callback\n");
988 nsres
= nsIWebProgress_GetDOMWindow(web_progress
, &nswindow
);
989 nsIWebProgress_Release(web_progress
);
990 if(NS_FAILED(nsres
) || !nswindow
) {
991 ERR("GetDOMWindow failed: %08x\n", nsres
);
995 window
= nswindow_to_window(nswindow
);
996 nsIDOMWindow_Release(nswindow
);
999 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
1001 FIXME("NULL window for %p\n", nswindow
);
1007 HTMLInnerWindow
*window
;
1008 nsChannelBSC
*bscallback
;
1009 } start_binding_task_t
;
1011 static void start_binding_proc(task_t
*_task
)
1013 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
1015 start_binding(task
->window
, (BSCallback
*)task
->bscallback
, NULL
);
1018 static void start_binding_task_destr(task_t
*_task
)
1020 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
1022 IBindStatusCallback_Release(&task
->bscallback
->bsc
.IBindStatusCallback_iface
);
1026 static nsresult
async_open(nsChannel
*This
, HTMLOuterWindow
*window
, BOOL is_doc_channel
, nsIStreamListener
*listener
,
1027 nsISupports
*context
)
1029 nsChannelBSC
*bscallback
;
1030 IMoniker
*mon
= NULL
;
1033 hres
= CreateURLMonikerEx2(NULL
, This
->uri
->uri
, &mon
, 0);
1035 WARN("CreateURLMoniker failed: %08x\n", hres
);
1036 return NS_ERROR_UNEXPECTED
;
1040 set_current_mon(window
, mon
, BINDING_NAVIGATED
);
1042 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, is_doc_channel
, &bscallback
);
1043 IMoniker_Release(mon
);
1045 return NS_ERROR_UNEXPECTED
;
1047 channelbsc_set_channel(bscallback
, This
, listener
, context
);
1049 if(is_doc_channel
) {
1050 hres
= create_pending_window(window
, bscallback
);
1052 async_start_doc_binding(window
, window
->pending_window
);
1053 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
1055 return NS_ERROR_UNEXPECTED
;
1057 start_binding_task_t
*task
;
1059 task
= heap_alloc(sizeof(start_binding_task_t
));
1061 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
1062 return NS_ERROR_OUT_OF_MEMORY
;
1065 task
->window
= window
->base
.inner_window
;
1066 task
->bscallback
= bscallback
;
1067 hres
= push_task(&task
->header
, start_binding_proc
, start_binding_task_destr
, window
->base
.inner_window
->task_magic
);
1069 return NS_ERROR_OUT_OF_MEMORY
;
1075 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
1076 nsISupports
*aContext
)
1078 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1079 HTMLOuterWindow
*window
= NULL
;
1080 BOOL cancel
= FALSE
;
1081 nsresult nsres
= NS_OK
;
1083 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
1085 if(!ensure_uri(This
->uri
))
1086 return NS_ERROR_FAILURE
;
1088 if(TRACE_ON(mshtml
)) {
1092 hres
= IUri_GetDisplayUri(This
->uri
->uri
, &uri_str
);
1093 if(SUCCEEDED(hres
)) {
1094 TRACE("opening %s\n", debugstr_w(uri_str
));
1095 SysFreeString(uri_str
);
1097 WARN("GetDisplayUri failed: %08x\n", hres
);
1101 if(This
->uri
->is_doc_uri
) {
1102 window
= get_channel_window(This
);
1104 set_uri_window(This
->uri
, window
);
1105 }else if(This
->uri
->container
) {
1108 /* nscontainer->doc should be NULL which means navigation to a new window */
1109 if(This
->uri
->container
->doc
)
1110 FIXME("nscontainer->doc = %p\n", This
->uri
->container
->doc
);
1112 nsres
= before_async_open(This
, This
->uri
->container
, &b
);
1113 if(NS_FAILED(nsres
))
1116 FIXME("Navigation not cancelled\n");
1117 return NS_ERROR_UNEXPECTED
;
1122 if(This
->uri
->window_ref
&& This
->uri
->window_ref
->window
) {
1123 window
= This
->uri
->window_ref
->window
;
1124 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
1126 /* FIXME: Analyze removing get_window_from_load_group call */
1127 if(This
->load_group
)
1128 window
= get_window_from_load_group(This
);
1130 window
= get_channel_window(This
);
1132 set_uri_window(This
->uri
, window
);
1137 ERR("window = NULL\n");
1138 return NS_ERROR_UNEXPECTED
;
1141 if(This
->uri
->is_doc_uri
&& window
== window
->doc_obj
->basedoc
.window
) {
1142 if(This
->uri
->channel_bsc
) {
1143 channelbsc_set_channel(This
->uri
->channel_bsc
, This
, aListener
, aContext
);
1145 if(window
->doc_obj
->mime
) {
1146 heap_free(This
->content_type
);
1147 This
->content_type
= heap_strdupWtoA(window
->doc_obj
->mime
);
1152 nsres
= before_async_open(This
, window
->doc_obj
->nscontainer
, &cancel
);
1153 if(NS_SUCCEEDED(nsres
) && cancel
) {
1154 TRACE("canceled\n");
1155 nsres
= NS_BINDING_ABORTED
;
1161 nsres
= async_open(This
, window
, This
->uri
->is_doc_uri
, aListener
, aContext
);
1163 if(NS_SUCCEEDED(nsres
) && This
->load_group
) {
1164 nsres
= nsILoadGroup_AddRequest(This
->load_group
, (nsIRequest
*)&This
->nsIHttpChannel_iface
,
1166 if(NS_FAILED(nsres
))
1167 ERR("AddRequest failed: %08x\n", nsres
);
1170 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
1174 static nsresult NSAPI
nsChannel_AsyncOpen2(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
)
1176 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1177 FIXME("(%p)->(%p)\n", This
, aListener
);
1178 return nsIHttpChannel_AsyncOpen(&This
->nsIHttpChannel_iface
, aListener
, NULL
);
1181 static nsresult NSAPI
nsChannel_GetContentDisposition(nsIHttpChannel
*iface
, UINT32
*aContentDisposition
)
1183 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1184 FIXME("(%p)->(%p)\n", This
, aContentDisposition
);
1185 return NS_ERROR_NOT_IMPLEMENTED
;
1188 static nsresult NSAPI
nsChannel_SetContentDisposition(nsIHttpChannel
*iface
, UINT32 aContentDisposition
)
1190 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1191 FIXME("(%p)->(%u)\n", This
, aContentDisposition
);
1192 return NS_ERROR_NOT_IMPLEMENTED
;
1195 static nsresult NSAPI
nsChannel_GetContentDispositionFilename(nsIHttpChannel
*iface
, nsAString
*aContentDispositionFilename
)
1197 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1198 FIXME("(%p)->(%p)\n", This
, aContentDispositionFilename
);
1199 return NS_ERROR_NOT_IMPLEMENTED
;
1202 static nsresult NSAPI
nsChannel_SetContentDispositionFilename(nsIHttpChannel
*iface
, const nsAString
*aContentDispositionFilename
)
1204 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1205 FIXME("(%p)->(%p)\n", This
, aContentDispositionFilename
);
1206 return NS_ERROR_NOT_IMPLEMENTED
;
1209 static nsresult NSAPI
nsChannel_GetContentDispositionHeader(nsIHttpChannel
*iface
, nsACString
*aContentDispositionHeader
)
1211 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1212 FIXME("(%p)->(%p)\n", This
, aContentDispositionHeader
);
1213 return NS_ERROR_NOT_IMPLEMENTED
;
1216 static nsresult NSAPI
nsChannel_GetLoadInfo(nsIHttpChannel
*iface
, nsILoadInfo
**aLoadInfo
)
1218 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1220 TRACE("(%p)->(%p)\n", This
, aLoadInfo
);
1223 nsISupports_AddRef(This
->load_info
);
1224 *aLoadInfo
= This
->load_info
;
1228 static nsresult NSAPI
nsChannel_SetLoadInfo(nsIHttpChannel
*iface
, nsILoadInfo
*aLoadInfo
)
1230 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1232 TRACE("(%p)->(%p)\n", This
, aLoadInfo
);
1235 nsISupports_Release(This
->load_info
);
1236 This
->load_info
= aLoadInfo
;
1238 nsISupports_AddRef(This
->load_info
);
1242 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
1244 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1246 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
1248 nsACString_SetData(aRequestMethod
, request_method_strings
[This
->request_method
]);
1252 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
1253 const nsACString
*aRequestMethod
)
1255 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1259 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRequestMethod
));
1261 nsACString_GetData(aRequestMethod
, &method
);
1262 for(i
=0; i
< sizeof(request_method_strings
)/sizeof(*request_method_strings
); i
++) {
1263 if(!strcasecmp(method
, request_method_strings
[i
])) {
1264 This
->request_method
= i
;
1269 ERR("Invalid method %s\n", debugstr_a(method
));
1270 return NS_ERROR_UNEXPECTED
;
1273 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
1275 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1277 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1280 nsIURI_AddRef(This
->referrer
);
1281 *aReferrer
= This
->referrer
;
1285 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
1287 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1289 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1292 nsIURI_AddRef(aReferrer
);
1294 nsIURI_Release(This
->referrer
);
1295 This
->referrer
= aReferrer
;
1299 static nsresult NSAPI
nsChannel_GetReferrerPolicy(nsIHttpChannel
*iface
, UINT32
*aReferrerPolicy
)
1301 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1302 FIXME("(%p)->(%p)\n", This
, aReferrerPolicy
);
1303 return NS_ERROR_NOT_IMPLEMENTED
;
1306 static nsresult NSAPI
nsChannel_SetReferrerWithPolicy(nsIHttpChannel
*iface
, nsIURI
*aReferrer
, UINT32 aReferrerPolicy
)
1308 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1309 FIXME("(%p)->(%p %x)\n", This
, aReferrer
, aReferrerPolicy
);
1310 return NS_ERROR_NOT_IMPLEMENTED
;
1313 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
1314 const nsACString
*aHeader
, nsACString
*_retval
)
1316 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1318 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aHeader
), _retval
);
1320 return get_channel_http_header(&This
->request_headers
, aHeader
, _retval
);
1323 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
1324 const nsACString
*aHeader
, const nsACString
*aValue
, cpp_bool aMerge
)
1326 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1328 TRACE("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(aHeader
), debugstr_nsacstr(aValue
), aMerge
);
1331 FIXME("aMerge not supported\n");
1333 return set_channel_http_header(&This
->request_headers
, aHeader
, aValue
);
1336 static nsresult NSAPI
nsChannel_SetEmptyRequestHeader(nsIHttpChannel
*iface
, const nsACString
*aHeader
)
1338 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1339 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aHeader
));
1340 return NS_ERROR_NOT_IMPLEMENTED
;
1343 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
1344 nsIHttpHeaderVisitor
*aVisitor
)
1346 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1348 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1350 return NS_ERROR_NOT_IMPLEMENTED
;
1353 static nsresult NSAPI
nsChannel_VisitNonDefaultRequestHeaders(nsIHttpChannel
*iface
, nsIHttpHeaderVisitor
*aVisitor
)
1355 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1356 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1357 return NS_ERROR_NOT_IMPLEMENTED
;
1360 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, cpp_bool
*aAllowPipelining
)
1362 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1364 FIXME("(%p)->(%p)\n", This
, aAllowPipelining
);
1366 return NS_ERROR_NOT_IMPLEMENTED
;
1369 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, cpp_bool aAllowPipelining
)
1371 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1373 FIXME("(%p)->(%x)\n", This
, aAllowPipelining
);
1375 return NS_ERROR_NOT_IMPLEMENTED
;
1378 static nsresult NSAPI
nsChannel_GetAllowTLS(nsIHttpChannel
*iface
, cpp_bool
*aAllowTLS
)
1380 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1381 FIXME("(%p)->(%p)\n", This
, aAllowTLS
);
1382 return NS_ERROR_NOT_IMPLEMENTED
;
1385 static nsresult NSAPI
nsChannel_SetAllowTLS(nsIHttpChannel
*iface
, cpp_bool aAllowTLS
)
1387 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1388 FIXME("(%p)->(%x)\n", This
, aAllowTLS
);
1389 return NS_ERROR_NOT_IMPLEMENTED
;
1392 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, UINT32
*aRedirectionLimit
)
1394 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1396 FIXME("(%p)->(%p)\n", This
, aRedirectionLimit
);
1398 return NS_ERROR_NOT_IMPLEMENTED
;
1401 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, UINT32 aRedirectionLimit
)
1403 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1405 FIXME("(%p)->(%u)\n", This
, aRedirectionLimit
);
1407 return NS_ERROR_NOT_IMPLEMENTED
;
1410 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, UINT32
*aResponseStatus
)
1412 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1414 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
1416 if(This
->response_status
) {
1417 *aResponseStatus
= This
->response_status
;
1421 WARN("No response status\n");
1422 return NS_ERROR_UNEXPECTED
;
1425 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
1426 nsACString
*aResponseStatusText
)
1428 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1430 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
1432 nsACString_SetData(aResponseStatusText
, This
->response_status_text
);
1436 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
1437 cpp_bool
*aRequestSucceeded
)
1439 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1441 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
1443 if(!This
->response_status
)
1444 return NS_ERROR_NOT_AVAILABLE
;
1446 *aRequestSucceeded
= This
->response_status
/100 == 2;
1451 static nsresult NSAPI
nsChannel_GetIsMainDocumentChannel(nsIHttpChannel
*iface
, cpp_bool
*aIsMainDocumentChannel
)
1453 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1454 FIXME("(%p)->(%p)\n", This
, aIsMainDocumentChannel
);
1455 return NS_ERROR_NOT_IMPLEMENTED
;
1458 static nsresult NSAPI
nsChannel_SetIsMainDocumentChannel(nsIHttpChannel
*iface
, cpp_bool aIsMainDocumentChannel
)
1460 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1461 FIXME("(%p)->(%x)\n", This
, aIsMainDocumentChannel
);
1462 return NS_ERROR_NOT_IMPLEMENTED
;
1465 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
1466 const nsACString
*header
, nsACString
*_retval
)
1468 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1470 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(header
), _retval
);
1472 return get_channel_http_header(&This
->response_headers
, header
, _retval
);
1475 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
1476 const nsACString
*header
, const nsACString
*value
, cpp_bool merge
)
1478 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1480 FIXME("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(header
), debugstr_nsacstr(value
), merge
);
1482 return NS_ERROR_NOT_IMPLEMENTED
;
1485 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
1486 nsIHttpHeaderVisitor
*aVisitor
)
1488 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1490 TRACE("(%p)->(%p)\n", This
, aVisitor
);
1492 return visit_http_headers(&This
->response_headers
, aVisitor
);
1495 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1497 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1498 http_header_t
*header
;
1500 static const WCHAR cache_controlW
[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l'};
1501 static const WCHAR no_storeW
[] = {'n','o','-','s','t','o','r','e',0};
1503 TRACE("(%p)->(%p)\n", This
, _retval
);
1505 header
= find_http_header(&This
->response_headers
, cache_controlW
, sizeof(cache_controlW
)/sizeof(WCHAR
));
1506 *_retval
= header
&& !strcmpiW(header
->data
, no_storeW
);
1510 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1512 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1514 FIXME("(%p)->(%p)\n", This
, _retval
);
1516 return NS_ERROR_NOT_IMPLEMENTED
;
1519 static nsresult NSAPI
nsChannel_IsPrivateResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1521 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1523 FIXME("(%p)->(%p)\n", This
, _retval
);
1525 return NS_ERROR_NOT_IMPLEMENTED
;
1528 static nsresult NSAPI
nsChannel_RedirectTo(nsIHttpChannel
*iface
, nsIURI
*aNewURI
)
1530 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1532 FIXME("(%p)->(%p)\n", This
, aNewURI
);
1534 return NS_ERROR_NOT_IMPLEMENTED
;
1537 static nsresult NSAPI
nsHttpChannel_GetSchedulingContextID(nsIHttpChannel
*iface
, nsIID
*aSchedulingContextID
)
1539 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1541 FIXME("(%p)->(%p)\n", This
, aSchedulingContextID
);
1543 return NS_ERROR_NOT_IMPLEMENTED
;
1546 static nsresult NSAPI
nsHttpChannel_SetSchedulingContextID(nsIHttpChannel
*iface
, const nsIID aSchedulingContextID
)
1548 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1550 FIXME("(%p)->(%s)\n", This
, debugstr_guid(&aSchedulingContextID
));
1552 return NS_ERROR_NOT_IMPLEMENTED
;
1555 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1556 nsChannel_QueryInterface
,
1560 nsChannel_IsPending
,
1561 nsChannel_GetStatus
,
1565 nsChannel_GetLoadGroup
,
1566 nsChannel_SetLoadGroup
,
1567 nsChannel_GetLoadFlags
,
1568 nsChannel_SetLoadFlags
,
1569 nsChannel_GetOriginalURI
,
1570 nsChannel_SetOriginalURI
,
1574 nsChannel_GetNotificationCallbacks
,
1575 nsChannel_SetNotificationCallbacks
,
1576 nsChannel_GetSecurityInfo
,
1577 nsChannel_GetContentType
,
1578 nsChannel_SetContentType
,
1579 nsChannel_GetContentCharset
,
1580 nsChannel_SetContentCharset
,
1581 nsChannel_GetContentLength
,
1582 nsChannel_SetContentLength
,
1585 nsChannel_AsyncOpen
,
1586 nsChannel_AsyncOpen2
,
1587 nsChannel_GetContentDisposition
,
1588 nsChannel_SetContentDisposition
,
1589 nsChannel_GetContentDispositionFilename
,
1590 nsChannel_SetContentDispositionFilename
,
1591 nsChannel_GetContentDispositionHeader
,
1592 nsChannel_GetLoadInfo
,
1593 nsChannel_SetLoadInfo
,
1594 nsChannel_GetRequestMethod
,
1595 nsChannel_SetRequestMethod
,
1596 nsChannel_GetReferrer
,
1597 nsChannel_SetReferrer
,
1598 nsChannel_GetReferrerPolicy
,
1599 nsChannel_SetReferrerWithPolicy
,
1600 nsChannel_GetRequestHeader
,
1601 nsChannel_SetRequestHeader
,
1602 nsChannel_SetEmptyRequestHeader
,
1603 nsChannel_VisitRequestHeaders
,
1604 nsChannel_VisitNonDefaultRequestHeaders
,
1605 nsChannel_GetAllowPipelining
,
1606 nsChannel_SetAllowPipelining
,
1607 nsChannel_GetAllowTLS
,
1608 nsChannel_SetAllowTLS
,
1609 nsChannel_GetRedirectionLimit
,
1610 nsChannel_SetRedirectionLimit
,
1611 nsChannel_GetResponseStatus
,
1612 nsChannel_GetResponseStatusText
,
1613 nsChannel_GetRequestSucceeded
,
1614 nsChannel_GetIsMainDocumentChannel
,
1615 nsChannel_SetIsMainDocumentChannel
,
1616 nsChannel_GetResponseHeader
,
1617 nsChannel_SetResponseHeader
,
1618 nsChannel_VisitResponseHeaders
,
1619 nsChannel_IsNoStoreResponse
,
1620 nsChannel_IsNoCacheResponse
,
1621 nsChannel_IsPrivateResponse
,
1622 nsChannel_RedirectTo
,
1623 nsHttpChannel_GetSchedulingContextID
,
1624 nsHttpChannel_SetSchedulingContextID
1627 static inline nsChannel
*impl_from_nsIUploadChannel(nsIUploadChannel
*iface
)
1629 return CONTAINING_RECORD(iface
, nsChannel
, nsIUploadChannel_iface
);
1632 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1635 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1636 return nsIHttpChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1639 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1641 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1642 return nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
1645 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1647 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1648 return nsIHttpChannel_Release(&This
->nsIHttpChannel_iface
);
1651 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1652 nsIInputStream
*aStream
, const nsACString
*aContentType
, INT64 aContentLength
)
1654 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1655 const char *content_type
;
1657 static const WCHAR content_typeW
[] =
1658 {'C','o','n','t','e','n','t','-','T','y','p','e',0};
1660 TRACE("(%p)->(%p %s %s)\n", This
, aStream
, debugstr_nsacstr(aContentType
), wine_dbgstr_longlong(aContentLength
));
1662 This
->post_data_contains_headers
= TRUE
;
1665 nsACString_GetData(aContentType
, &content_type
);
1669 ct
= heap_strdupAtoW(content_type
);
1671 return NS_ERROR_UNEXPECTED
;
1673 set_http_header(&This
->request_headers
, content_typeW
,
1674 sizeof(content_typeW
)/sizeof(WCHAR
), ct
, strlenW(ct
));
1676 This
->post_data_contains_headers
= FALSE
;
1680 if(aContentLength
!= -1)
1681 FIXME("Unsupported acontentLength = %s\n", wine_dbgstr_longlong(aContentLength
));
1683 if(This
->post_data_stream
)
1684 nsIInputStream_Release(This
->post_data_stream
);
1685 This
->post_data_stream
= aStream
;
1687 nsIInputStream_AddRef(aStream
);
1689 This
->request_method
= METHOD_POST
;
1693 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1694 nsIInputStream
**aUploadStream
)
1696 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1698 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1700 if(This
->post_data_stream
)
1701 nsIInputStream_AddRef(This
->post_data_stream
);
1703 *aUploadStream
= This
->post_data_stream
;
1707 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1708 nsUploadChannel_QueryInterface
,
1709 nsUploadChannel_AddRef
,
1710 nsUploadChannel_Release
,
1711 nsUploadChannel_SetUploadStream
,
1712 nsUploadChannel_GetUploadStream
1715 static inline nsChannel
*impl_from_nsIHttpChannelInternal(nsIHttpChannelInternal
*iface
)
1717 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannelInternal_iface
);
1720 static nsresult NSAPI
nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal
*iface
, nsIIDRef riid
,
1723 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1724 return nsIHttpChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1727 static nsrefcnt NSAPI
nsHttpChannelInternal_AddRef(nsIHttpChannelInternal
*iface
)
1729 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1730 return nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
1733 static nsrefcnt NSAPI
nsHttpChannelInternal_Release(nsIHttpChannelInternal
*iface
)
1735 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1736 return nsIHttpChannel_Release(&This
->nsIHttpChannel_iface
);
1739 static nsresult NSAPI
nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
**aDocumentURI
)
1741 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1743 FIXME("(%p)->()\n", This
);
1745 return NS_ERROR_NOT_IMPLEMENTED
;
1748 static nsresult NSAPI
nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
*aDocumentURI
)
1750 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1752 FIXME("(%p)->()\n", This
);
1754 return NS_ERROR_NOT_IMPLEMENTED
;
1757 static nsresult NSAPI
nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal
*iface
, UINT32
*major
, UINT32
*minor
)
1759 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1761 FIXME("(%p)->()\n", This
);
1763 return NS_ERROR_NOT_IMPLEMENTED
;
1766 static nsresult NSAPI
nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal
*iface
, UINT32
*major
, UINT32
*minor
)
1768 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1770 FIXME("(%p)->()\n", This
);
1772 return NS_ERROR_NOT_IMPLEMENTED
;
1775 static nsresult NSAPI
nsHttpChannelInternal_TakeAllSecurityMessages(nsIHttpChannelInternal
*iface
, void *aMessages
)
1777 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1779 FIXME("(%p)->()\n", This
);
1781 return NS_ERROR_NOT_IMPLEMENTED
;
1784 static nsresult NSAPI
nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal
*iface
, const char *aCookieHeader
)
1786 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1788 FIXME("(%p)->()\n", This
);
1790 return NS_ERROR_NOT_IMPLEMENTED
;
1793 static nsresult NSAPI
nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal
*iface
, const char *aFallbackKey
)
1795 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1797 FIXME("(%p)->()\n", This
);
1799 return NS_ERROR_NOT_IMPLEMENTED
;
1802 static nsresult NSAPI
nsHttpChannelInternal_GetThirdPartyFlags(nsIHttpChannelInternal
*iface
, UINT32
*aThirdPartyFlags
)
1804 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1805 FIXME("(%p)->(%p)\n", This
, aThirdPartyFlags
);
1806 return NS_ERROR_NOT_IMPLEMENTED
;
1809 static nsresult NSAPI
nsHttpChannelInternal_SetThirdPartyFlags(nsIHttpChannelInternal
*iface
, UINT32 aThirdPartyFlags
)
1811 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1812 FIXME("(%p)->(%x)\n", This
, aThirdPartyFlags
);
1813 return NS_ERROR_NOT_IMPLEMENTED
;
1816 static nsresult NSAPI
nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, cpp_bool
*aForceThirdPartyCookie
)
1818 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1820 FIXME("(%p)->()\n", This
);
1822 return NS_ERROR_NOT_IMPLEMENTED
;
1825 static nsresult NSAPI
nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, cpp_bool aForceThirdPartyCookie
)
1827 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1829 FIXME("(%p)->()\n", This
);
1831 return NS_ERROR_NOT_IMPLEMENTED
;
1834 static nsresult NSAPI
nsHttpChannelInternal_GetCanceled(nsIHttpChannelInternal
*iface
, cpp_bool
*aCanceled
)
1836 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1838 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1840 return NS_ERROR_NOT_IMPLEMENTED
;
1843 static nsresult NSAPI
nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal
*iface
, cpp_bool
*aCanceled
)
1845 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1847 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1849 return NS_ERROR_NOT_IMPLEMENTED
;
1852 static nsresult NSAPI
nsHttpChannelInternal_SetChannelIsForDownload(nsIHttpChannelInternal
*iface
, cpp_bool aCanceled
)
1854 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1856 FIXME("(%p)->(%x)\n", This
, aCanceled
);
1858 return NS_ERROR_NOT_IMPLEMENTED
;
1861 static nsresult NSAPI
nsHttpChannelInternal_GetLocalAddress(nsIHttpChannelInternal
*iface
, nsACString
*aLocalAddress
)
1863 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1865 FIXME("(%p)->(%p)\n", This
, aLocalAddress
);
1867 return NS_ERROR_NOT_IMPLEMENTED
;
1870 static nsresult NSAPI
nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal
*iface
, LONG
*aLocalPort
)
1872 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1874 FIXME("(%p)->(%p)\n", This
, aLocalPort
);
1876 return NS_ERROR_NOT_IMPLEMENTED
;
1879 static nsresult NSAPI
nsHttpChannelInternal_GetRemoteAddress(nsIHttpChannelInternal
*iface
, nsACString
*aRemoteAddress
)
1881 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1883 FIXME("(%p)->(%p)\n", This
, aRemoteAddress
);
1885 return NS_ERROR_NOT_IMPLEMENTED
;
1888 static nsresult NSAPI
nsHttpChannelInternal_GetRemotePort(nsIHttpChannelInternal
*iface
, LONG
*aRemotePort
)
1890 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1892 FIXME("(%p)->(%p)\n", This
, aRemotePort
);
1894 return NS_ERROR_NOT_IMPLEMENTED
;
1897 static nsresult NSAPI
nsHttpChannelInternal_SetCacheKeysRedirectChain(nsIHttpChannelInternal
*iface
, void *cacheKeys
)
1899 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1901 FIXME("(%p)->(%p)\n", This
, cacheKeys
);
1903 return NS_ERROR_NOT_IMPLEMENTED
;
1906 static nsresult NSAPI
nsHttpChannelInternal_HTTPUpgrade(nsIHttpChannelInternal
*iface
,
1907 const nsACString
*aProtocolName
, nsIHttpUpgradeListener
*aListener
)
1909 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1910 FIXME("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aProtocolName
), aListener
);
1911 return NS_ERROR_NOT_IMPLEMENTED
;
1914 static nsresult NSAPI
nsHttpChannelInternal_GetAllowSpdy(nsIHttpChannelInternal
*iface
, cpp_bool
*aAllowSpdy
)
1916 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1917 FIXME("(%p)->(%p)\n", This
, aAllowSpdy
);
1918 return NS_ERROR_NOT_IMPLEMENTED
;
1921 static nsresult NSAPI
nsHttpChannelInternal_SetAllowSpdy(nsIHttpChannelInternal
*iface
, cpp_bool aAllowSpdy
)
1923 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1924 FIXME("(%p)->(%x)\n", This
, aAllowSpdy
);
1925 return NS_ERROR_NOT_IMPLEMENTED
;
1928 static nsresult NSAPI
nsHttpChannelInternal_GetResponseTimeoutEnabled(nsIHttpChannelInternal
*iface
,
1929 cpp_bool
*aResponseTimeoutEnabled
)
1931 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1932 FIXME("(%p)->(%p)\n", This
, aResponseTimeoutEnabled
);
1933 return NS_ERROR_NOT_IMPLEMENTED
;
1936 static nsresult NSAPI
nsHttpChannelInternal_SetResponseTimeoutEnabled(nsIHttpChannelInternal
*iface
,
1937 cpp_bool aResponseTimeoutEnabled
)
1939 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1940 FIXME("(%p)->(%x)\n", This
, aResponseTimeoutEnabled
);
1941 return NS_ERROR_NOT_IMPLEMENTED
;
1944 static nsresult NSAPI
nsHttpChannelInternal_GetInitialRwin(nsIHttpChannelInternal
*iface
,
1945 UINT32
*aInitialRwin
)
1947 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1948 FIXME("(%p)->(%p)\n", This
, aInitialRwin
);
1949 return NS_ERROR_NOT_IMPLEMENTED
;
1952 static nsresult NSAPI
nsHttpChannelInternal_SetInitialRwin(nsIHttpChannelInternal
*iface
,
1953 UINT32 aInitialRwin
)
1955 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1956 FIXME("(%p)->(%x)\n", This
, aInitialRwin
);
1957 return NS_ERROR_NOT_IMPLEMENTED
;
1960 static nsresult NSAPI
nsHttpChannelInternal_GetApiRedirectToURI(nsIHttpChannelInternal
*iface
, nsIURI
**aApiRedirectToURI
)
1962 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1963 FIXME("(%p)->(%p)\n", This
, aApiRedirectToURI
);
1964 return NS_ERROR_NOT_IMPLEMENTED
;
1967 static nsresult NSAPI
nsHttpChannelInternal_GetAllowAltSvc(nsIHttpChannelInternal
*iface
, cpp_bool
*aAllowAltSvc
)
1969 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1970 FIXME("(%p)->(%p)\n", This
, aAllowAltSvc
);
1971 return NS_ERROR_NOT_IMPLEMENTED
;
1974 static nsresult NSAPI
nsHttpChannelInternal_SetAllowAltSvc(nsIHttpChannelInternal
*iface
, cpp_bool aAllowAltSvc
)
1976 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1977 FIXME("(%p)->(%x)\n", This
, aAllowAltSvc
);
1978 return NS_ERROR_NOT_IMPLEMENTED
;
1981 static nsresult NSAPI
nsHttpChannelInternal_GetLastModifiedTime(nsIHttpChannelInternal
*iface
, PRTime
*aLastModifiedTime
)
1983 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1984 FIXME("(%p)->(%p)\n", This
, aLastModifiedTime
);
1985 return NS_ERROR_NOT_IMPLEMENTED
;
1988 static nsresult NSAPI
nsHttpChannelInternal_ForceIntercepted(nsIHttpChannelInternal
*iface
, UINT64 aInterceptionID
)
1990 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1991 FIXME("(%p)->(%s)\n", This
, wine_dbgstr_longlong(aInterceptionID
));
1992 return NS_ERROR_NOT_IMPLEMENTED
;
1995 static nsresult NSAPI
nsHttpChannelInternal_GetResponseSynthesized(nsIHttpChannelInternal
*iface
, cpp_bool
*ResponseSynthesized
)
1997 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1998 FIXME("(%p, %p)\n", This
, ResponseSynthesized
);
1999 return NS_ERROR_NOT_IMPLEMENTED
;
2002 static nsresult NSAPI
nsHttpChannelInternal_GetCorsIncludeCredentials(nsIHttpChannelInternal
*iface
,
2003 cpp_bool
*aCorsIncludeCredentials
)
2005 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2006 FIXME("(%p)->(%p)\n", This
, aCorsIncludeCredentials
);
2007 return NS_ERROR_NOT_IMPLEMENTED
;
2010 static nsresult NSAPI
nsHttpChannelInternal_SetCorsIncludeCredentials(nsIHttpChannelInternal
*iface
,
2011 cpp_bool aCorsIncludeCredentials
)
2013 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2014 TRACE("(%p)->(%x)\n", This
, aCorsIncludeCredentials
);
2018 static nsresult NSAPI
nsHttpChannelInternal_GetCorsMode(nsIHttpChannelInternal
*iface
, UINT32
*aCorsMode
)
2020 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2021 FIXME("(%p)->(%p)\n", This
, aCorsMode
);
2022 return NS_ERROR_NOT_IMPLEMENTED
;
2025 static nsresult NSAPI
nsHttpChannelInternal_SetCorsMode(nsIHttpChannelInternal
*iface
, UINT32 aCorsMode
)
2027 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2028 TRACE("(%p)->(%d)\n", This
, aCorsMode
);
2032 static nsresult NSAPI
nsHttpChannelInternal_GetRedirectMode(nsIHttpChannelInternal
*iface
, UINT32
*aRedirectMode
)
2034 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2035 FIXME("(%p)->(%p)\n", This
, aRedirectMode
);
2036 return NS_ERROR_NOT_IMPLEMENTED
;
2039 static nsresult NSAPI
nsHttpChannelInternal_SetRedirectMode(nsIHttpChannelInternal
*iface
, UINT32 aRedirectMode
)
2041 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2042 FIXME("(%p)->(%d)\n", This
, aRedirectMode
);
2043 return NS_ERROR_NOT_IMPLEMENTED
;
2046 static nsresult NSAPI
nsHttpChannelInternal_GetTopWindowURI(nsIHttpChannelInternal
*iface
, nsIURI
**aTopWindowURI
)
2048 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2049 FIXME("(%p)->(%p)\n", This
, aTopWindowURI
);
2050 return NS_ERROR_NOT_IMPLEMENTED
;
2053 static nsresult NSAPI
nsHttpChannelInternal_GetNetworkInterfaceId(nsIHttpChannelInternal
*iface
,
2054 nsACString
*aNetworkInterfaceId
)
2056 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2057 FIXME("(%p)->(%p)\n", This
, aNetworkInterfaceId
);
2058 return NS_ERROR_NOT_IMPLEMENTED
;
2061 static nsresult NSAPI
nsHttpChannelInternal_SetNetworkInterfaceId(nsIHttpChannelInternal
*iface
,
2062 const nsACString
*aNetworkInterfaceId
)
2064 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2065 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aNetworkInterfaceId
));
2066 return NS_ERROR_NOT_IMPLEMENTED
;
2069 static nsresult NSAPI
nsHttpChannelInternal_GetProxyURI(nsIHttpChannelInternal
*iface
, nsIURI
**aProxyURI
)
2071 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2072 FIXME("(%p)->(%p)\n", This
, aProxyURI
);
2073 return NS_ERROR_NOT_IMPLEMENTED
;
2076 static nsresult NSAPI
nsHttpChannelInternal_SetCorsPreflightParameters(nsIHttpChannelInternal
*iface
,
2077 const void /*nsTArray<nsCString>*/ *unsafeHeaders
, cpp_bool withCredentials
, nsIPrincipal
*preflightPrincipal
)
2079 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2080 FIXME("(%p %p %x %p)\n", This
, unsafeHeaders
, withCredentials
, preflightPrincipal
);
2081 return NS_ERROR_NOT_IMPLEMENTED
;
2084 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl
= {
2085 nsHttpChannelInternal_QueryInterface
,
2086 nsHttpChannelInternal_AddRef
,
2087 nsHttpChannelInternal_Release
,
2088 nsHttpChannelInternal_GetDocumentURI
,
2089 nsHttpChannelInternal_SetDocumentURI
,
2090 nsHttpChannelInternal_GetRequestVersion
,
2091 nsHttpChannelInternal_GetResponseVersion
,
2092 nsHttpChannelInternal_TakeAllSecurityMessages
,
2093 nsHttpChannelInternal_SetCookie
,
2094 nsHttpChannelInternal_SetupFallbackChannel
,
2095 nsHttpChannelInternal_GetThirdPartyFlags
,
2096 nsHttpChannelInternal_SetThirdPartyFlags
,
2097 nsHttpChannelInternal_GetForceAllowThirdPartyCookie
,
2098 nsHttpChannelInternal_SetForceAllowThirdPartyCookie
,
2099 nsHttpChannelInternal_GetCanceled
,
2100 nsHttpChannelInternal_GetChannelIsForDownload
,
2101 nsHttpChannelInternal_SetChannelIsForDownload
,
2102 nsHttpChannelInternal_GetLocalAddress
,
2103 nsHttpChannelInternal_GetLocalPort
,
2104 nsHttpChannelInternal_GetRemoteAddress
,
2105 nsHttpChannelInternal_GetRemotePort
,
2106 nsHttpChannelInternal_SetCacheKeysRedirectChain
,
2107 nsHttpChannelInternal_HTTPUpgrade
,
2108 nsHttpChannelInternal_GetAllowSpdy
,
2109 nsHttpChannelInternal_SetAllowSpdy
,
2110 nsHttpChannelInternal_GetResponseTimeoutEnabled
,
2111 nsHttpChannelInternal_SetResponseTimeoutEnabled
,
2112 nsHttpChannelInternal_GetInitialRwin
,
2113 nsHttpChannelInternal_SetInitialRwin
,
2114 nsHttpChannelInternal_GetApiRedirectToURI
,
2115 nsHttpChannelInternal_GetAllowAltSvc
,
2116 nsHttpChannelInternal_SetAllowAltSvc
,
2117 nsHttpChannelInternal_GetLastModifiedTime
,
2118 nsHttpChannelInternal_ForceIntercepted
,
2119 nsHttpChannelInternal_GetResponseSynthesized
,
2120 nsHttpChannelInternal_GetCorsIncludeCredentials
,
2121 nsHttpChannelInternal_SetCorsIncludeCredentials
,
2122 nsHttpChannelInternal_GetCorsMode
,
2123 nsHttpChannelInternal_SetCorsMode
,
2124 nsHttpChannelInternal_GetRedirectMode
,
2125 nsHttpChannelInternal_SetRedirectMode
,
2126 nsHttpChannelInternal_GetTopWindowURI
,
2127 nsHttpChannelInternal_GetNetworkInterfaceId
,
2128 nsHttpChannelInternal_SetNetworkInterfaceId
,
2129 nsHttpChannelInternal_GetProxyURI
,
2130 nsHttpChannelInternal_SetCorsPreflightParameters
2134 static void invalidate_uri(nsWineURI
*This
)
2137 IUri_Release(This
->uri
);
2142 static BOOL
ensure_uri_builder(nsWineURI
*This
)
2144 if(!This
->is_mutable
) {
2145 WARN("Not mutable URI\n");
2149 if(!This
->uri_builder
) {
2152 if(!ensure_uri(This
))
2155 hres
= CreateIUriBuilder(This
->uri
, 0, 0, &This
->uri_builder
);
2157 WARN("CreateIUriBuilder failed: %08x\n", hres
);
2162 invalidate_uri(This
);
2166 static nsresult
get_uri_string(nsWineURI
*This
, Uri_PROPERTY prop
, nsACString
*ret
)
2172 if(!ensure_uri(This
))
2173 return NS_ERROR_UNEXPECTED
;
2175 hres
= IUri_GetPropertyBSTR(This
->uri
, prop
, &val
, 0);
2177 WARN("GetPropertyBSTR failed: %08x\n", hres
);
2178 return NS_ERROR_UNEXPECTED
;
2181 vala
= heap_strdupWtoU(val
);
2184 return NS_ERROR_OUT_OF_MEMORY
;
2186 TRACE("ret %s\n", debugstr_a(vala
));
2187 nsACString_SetData(ret
, vala
);
2192 static inline nsWineURI
*impl_from_nsIFileURL(nsIFileURL
*iface
)
2194 return CONTAINING_RECORD(iface
, nsWineURI
, nsIFileURL_iface
);
2197 static nsresult NSAPI
nsURI_QueryInterface(nsIFileURL
*iface
, nsIIDRef riid
, void **result
)
2199 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2203 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2204 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
2205 *result
= &This
->nsIFileURL_iface
;
2206 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
2207 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
2208 *result
= &This
->nsIFileURL_iface
;
2209 }else if(IsEqualGUID(&IID_nsIURL
, riid
)) {
2210 TRACE("(%p)->(IID_nsIURL %p)\n", This
, result
);
2211 *result
= &This
->nsIFileURL_iface
;
2212 }else if(IsEqualGUID(&IID_nsIFileURL
, riid
)) {
2213 TRACE("(%p)->(IID_nsIFileURL %p)\n", This
, result
);
2214 *result
= This
->scheme
== URL_SCHEME_FILE
? &This
->nsIFileURL_iface
: NULL
;
2215 }else if(IsEqualGUID(&IID_nsIMutable
, riid
)) {
2216 TRACE("(%p)->(IID_nsIMutable %p)\n", This
, result
);
2217 *result
= &This
->nsIStandardURL_iface
;
2218 }else if(IsEqualGUID(&IID_nsIStandardURL
, riid
)) {
2219 TRACE("(%p)->(IID_nsIStandardURL %p)\n", This
, result
);
2220 *result
= &This
->nsIStandardURL_iface
;
2221 }else if(IsEqualGUID(&IID_nsWineURI
, riid
)) {
2222 TRACE("(%p)->(IID_nsWineURI %p)\n", This
, result
);
2227 nsIFileURL_AddRef(&This
->nsIFileURL_iface
);
2231 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
2232 return NS_NOINTERFACE
;
2235 static nsrefcnt NSAPI
nsURI_AddRef(nsIFileURL
*iface
)
2237 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2238 LONG ref
= InterlockedIncrement(&This
->ref
);
2240 TRACE("(%p) ref=%d\n", This
, ref
);
2245 static nsrefcnt NSAPI
nsURI_Release(nsIFileURL
*iface
)
2247 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2248 LONG ref
= InterlockedDecrement(&This
->ref
);
2250 TRACE("(%p) ref=%d\n", This
, ref
);
2253 if(This
->window_ref
)
2254 windowref_release(This
->window_ref
);
2256 nsIWebBrowserChrome_Release(&This
->container
->nsIWebBrowserChrome_iface
);
2258 IUri_Release(This
->uri
);
2259 heap_free(This
->origin_charset
);
2266 static nsresult NSAPI
nsURI_GetSpec(nsIFileURL
*iface
, nsACString
*aSpec
)
2268 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2270 TRACE("(%p)->(%p)\n", This
, aSpec
);
2272 return get_uri_string(This
, Uri_PROPERTY_DISPLAY_URI
, aSpec
);
2275 static nsresult NSAPI
nsURI_SetSpec(nsIFileURL
*iface
, const nsACString
*aSpec
)
2277 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2283 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aSpec
));
2285 if(!This
->is_mutable
)
2286 return NS_ERROR_UNEXPECTED
;
2288 nsACString_GetData(aSpec
, &speca
);
2289 spec
= heap_strdupUtoW(speca
);
2291 return NS_ERROR_OUT_OF_MEMORY
;
2293 hres
= create_uri(spec
, 0, &uri
);
2296 WARN("create_uri failed: %08x\n", hres
);
2297 return NS_ERROR_FAILURE
;
2300 invalidate_uri(This
);
2301 if(This
->uri_builder
) {
2302 IUriBuilder_Release(This
->uri_builder
);
2303 This
->uri_builder
= NULL
;
2310 static nsresult NSAPI
nsURI_GetPrePath(nsIFileURL
*iface
, nsACString
*aPrePath
)
2312 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2313 IUriBuilder
*uri_builder
;
2320 TRACE("(%p)->(%p)\n", This
, aPrePath
);
2322 if(!ensure_uri(This
))
2323 return NS_ERROR_UNEXPECTED
;
2325 hres
= CreateIUriBuilder(This
->uri
, 0, 0, &uri_builder
);
2327 return NS_ERROR_FAILURE
;
2329 hres
= IUriBuilder_RemoveProperties(uri_builder
, Uri_HAS_PATH
|Uri_HAS_QUERY
|Uri_HAS_FRAGMENT
);
2331 hres
= IUriBuilder_CreateUriSimple(uri_builder
, 0, 0, &uri
);
2332 IUriBuilder_Release(uri_builder
);
2334 return NS_ERROR_FAILURE
;
2336 hres
= IUri_GetDisplayUri(uri
, &display_uri
);
2339 return NS_ERROR_FAILURE
;
2341 /* Remove trailing slash that may be appended as default path. */
2342 len
= SysStringLen(display_uri
);
2343 if(len
&& display_uri
[len
-1] == '/')
2344 display_uri
[len
-1] = 0;
2346 nsres
= return_wstr_nsacstr(aPrePath
, display_uri
, -1);
2347 SysFreeString(display_uri
);
2351 static nsresult NSAPI
nsURI_GetScheme(nsIFileURL
*iface
, nsACString
*aScheme
)
2353 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2357 TRACE("(%p)->(%p)\n", This
, aScheme
);
2359 if(!ensure_uri(This
))
2360 return NS_ERROR_UNEXPECTED
;
2362 hres
= IUri_GetScheme(This
->uri
, &scheme
);
2364 WARN("GetScheme failed: %08x\n", hres
);
2365 return NS_ERROR_UNEXPECTED
;
2368 if(scheme
== URL_SCHEME_ABOUT
) {
2369 nsACString_SetData(aScheme
, "wine");
2373 return get_uri_string(This
, Uri_PROPERTY_SCHEME_NAME
, aScheme
);
2376 static nsresult NSAPI
nsURI_SetScheme(nsIFileURL
*iface
, const nsACString
*aScheme
)
2378 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2379 const char *schemea
;
2383 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aScheme
));
2385 if(!ensure_uri_builder(This
))
2386 return NS_ERROR_UNEXPECTED
;
2388 nsACString_GetData(aScheme
, &schemea
);
2389 scheme
= heap_strdupUtoW(schemea
);
2391 return NS_ERROR_OUT_OF_MEMORY
;
2393 hres
= IUriBuilder_SetSchemeName(This
->uri_builder
, scheme
);
2396 return NS_ERROR_UNEXPECTED
;
2401 static nsresult NSAPI
nsURI_GetUserPass(nsIFileURL
*iface
, nsACString
*aUserPass
)
2403 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2407 TRACE("(%p)->(%p)\n", This
, aUserPass
);
2409 if(!ensure_uri(This
))
2410 return NS_ERROR_UNEXPECTED
;
2412 hres
= IUri_GetUserName(This
->uri
, &user
);
2414 return NS_ERROR_FAILURE
;
2416 hres
= IUri_GetPassword(This
->uri
, &pass
);
2418 SysFreeString(user
);
2419 return NS_ERROR_FAILURE
;
2422 if(*user
|| *pass
) {
2423 FIXME("Construct user:pass string\n");
2425 nsACString_SetData(aUserPass
, "");
2428 SysFreeString(user
);
2429 SysFreeString(pass
);
2433 static nsresult NSAPI
nsURI_SetUserPass(nsIFileURL
*iface
, const nsACString
*aUserPass
)
2435 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2436 WCHAR
*user
= NULL
, *pass
= NULL
, *buf
= NULL
;
2437 const char *user_pass
;
2440 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUserPass
));
2442 if(!ensure_uri_builder(This
))
2443 return NS_ERROR_UNEXPECTED
;
2445 nsACString_GetData(aUserPass
, &user_pass
);
2449 buf
= heap_strdupUtoW(user_pass
);
2451 return NS_ERROR_OUT_OF_MEMORY
;
2453 ptr
= strchrW(buf
, ':');
2456 }else if(ptr
!= buf
) {
2466 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
2468 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
2471 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
2474 static nsresult NSAPI
nsURI_GetUsername(nsIFileURL
*iface
, nsACString
*aUsername
)
2476 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2478 TRACE("(%p)->(%p)\n", This
, aUsername
);
2480 return get_uri_string(This
, Uri_PROPERTY_USER_NAME
, aUsername
);
2483 static nsresult NSAPI
nsURI_SetUsername(nsIFileURL
*iface
, const nsACString
*aUsername
)
2485 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2490 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUsername
));
2492 if(!ensure_uri_builder(This
))
2493 return NS_ERROR_UNEXPECTED
;
2495 nsACString_GetData(aUsername
, &usera
);
2496 user
= heap_strdupUtoW(usera
);
2498 return NS_ERROR_OUT_OF_MEMORY
;
2500 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
2503 return NS_ERROR_UNEXPECTED
;
2508 static nsresult NSAPI
nsURI_GetPassword(nsIFileURL
*iface
, nsACString
*aPassword
)
2510 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2512 TRACE("(%p)->(%p)\n", This
, aPassword
);
2514 return get_uri_string(This
, Uri_PROPERTY_PASSWORD
, aPassword
);
2517 static nsresult NSAPI
nsURI_SetPassword(nsIFileURL
*iface
, const nsACString
*aPassword
)
2519 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2524 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPassword
));
2526 if(!ensure_uri_builder(This
))
2527 return NS_ERROR_UNEXPECTED
;
2529 nsACString_GetData(aPassword
, &passa
);
2530 pass
= heap_strdupUtoW(passa
);
2532 return NS_ERROR_OUT_OF_MEMORY
;
2534 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
2537 return NS_ERROR_UNEXPECTED
;
2542 static nsresult NSAPI
nsURI_GetHostPort(nsIFileURL
*iface
, nsACString
*aHostPort
)
2544 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2550 TRACE("(%p)->(%p)\n", This
, aHostPort
);
2552 if(!ensure_uri(This
))
2553 return NS_ERROR_UNEXPECTED
;
2555 hres
= IUri_GetAuthority(This
->uri
, &val
);
2557 WARN("GetAuthority failed: %08x\n", hres
);
2558 return NS_ERROR_UNEXPECTED
;
2561 ptr
= strchrW(val
, '@');
2565 vala
= heap_strdupWtoU(ptr
);
2568 return NS_ERROR_OUT_OF_MEMORY
;
2570 TRACE("ret %s\n", debugstr_a(vala
));
2571 nsACString_SetData(aHostPort
, vala
);
2576 static nsresult NSAPI
nsURI_SetHostPort(nsIFileURL
*iface
, const nsACString
*aHostPort
)
2578 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2580 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aHostPort
));
2582 /* Not implemented by Gecko */
2583 return NS_ERROR_NOT_IMPLEMENTED
;
2586 static nsresult NSAPI
nsURI_GetHost(nsIFileURL
*iface
, nsACString
*aHost
)
2588 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2590 TRACE("(%p)->(%p)\n", This
, aHost
);
2592 return get_uri_string(This
, Uri_PROPERTY_HOST
, aHost
);
2595 static nsresult NSAPI
nsURI_SetHost(nsIFileURL
*iface
, const nsACString
*aHost
)
2597 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2602 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aHost
));
2604 if(!ensure_uri_builder(This
))
2605 return NS_ERROR_UNEXPECTED
;
2607 nsACString_GetData(aHost
, &hosta
);
2608 host
= heap_strdupUtoW(hosta
);
2610 return NS_ERROR_OUT_OF_MEMORY
;
2612 hres
= IUriBuilder_SetHost(This
->uri_builder
, host
);
2615 return NS_ERROR_UNEXPECTED
;
2620 static nsresult NSAPI
nsURI_GetPort(nsIFileURL
*iface
, LONG
*aPort
)
2622 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2626 TRACE("(%p)->(%p)\n", This
, aPort
);
2628 if(!ensure_uri(This
))
2629 return NS_ERROR_UNEXPECTED
;
2631 hres
= IUri_GetPort(This
->uri
, &port
);
2633 WARN("GetPort failed: %08x\n", hres
);
2634 return NS_ERROR_UNEXPECTED
;
2637 *aPort
= port
? port
: -1;
2641 static nsresult NSAPI
nsURI_SetPort(nsIFileURL
*iface
, LONG aPort
)
2643 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2646 TRACE("(%p)->(%d)\n", This
, aPort
);
2648 if(!ensure_uri_builder(This
))
2649 return NS_ERROR_UNEXPECTED
;
2651 hres
= IUriBuilder_SetPort(This
->uri_builder
, aPort
!= -1, aPort
);
2652 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
2655 static nsresult NSAPI
nsURI_GetPath(nsIFileURL
*iface
, nsACString
*aPath
)
2657 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2659 TRACE("(%p)->(%p)\n", This
, aPath
);
2661 return get_uri_string(This
, Uri_PROPERTY_PATH
, aPath
);
2664 static nsresult NSAPI
nsURI_SetPath(nsIFileURL
*iface
, const nsACString
*aPath
)
2666 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2671 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPath
));
2673 if(!ensure_uri_builder(This
))
2674 return NS_ERROR_UNEXPECTED
;
2676 nsACString_GetData(aPath
, &patha
);
2677 path
= heap_strdupUtoW(patha
);
2679 return NS_ERROR_OUT_OF_MEMORY
;
2681 hres
= IUriBuilder_SetPath(This
->uri_builder
, path
);
2684 return NS_ERROR_UNEXPECTED
;
2689 static nsresult NSAPI
nsURI_Equals(nsIFileURL
*iface
, nsIURI
*other
, cpp_bool
*_retval
)
2691 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2692 nsWineURI
*other_obj
;
2696 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2698 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2699 if(NS_FAILED(nsres
)) {
2700 TRACE("Could not get nsWineURI interface\n");
2705 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2708 hres
= IUri_IsEqual(This
->uri
, other_obj
->uri
, &b
);
2709 if(SUCCEEDED(hres
)) {
2713 nsres
= NS_ERROR_FAILURE
;
2716 nsres
= NS_ERROR_UNEXPECTED
;
2719 nsIFileURL_Release(&other_obj
->nsIFileURL_iface
);
2723 static nsresult NSAPI
nsURI_SchemeIs(nsIFileURL
*iface
, const char *scheme
, cpp_bool
*_retval
)
2725 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2726 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
2730 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
2732 if(!ensure_uri(This
))
2733 return NS_ERROR_UNEXPECTED
;
2735 hres
= IUri_GetSchemeName(This
->uri
, &scheme_name
);
2737 return NS_ERROR_UNEXPECTED
;
2739 MultiByteToWideChar(CP_UTF8
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
2740 *_retval
= !strcmpW(scheme_name
, buf
);
2741 SysFreeString(scheme_name
);
2745 static nsresult NSAPI
nsURI_Clone(nsIFileURL
*iface
, nsIURI
**_retval
)
2747 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2748 nsWineURI
*wine_uri
;
2751 TRACE("(%p)->(%p)\n", This
, _retval
);
2753 if(!ensure_uri(This
))
2754 return NS_ERROR_UNEXPECTED
;
2756 nsres
= create_nsuri(This
->uri
, This
->window_ref
? This
->window_ref
->window
: NULL
,
2757 This
->container
, This
->origin_charset
, &wine_uri
);
2758 if(NS_FAILED(nsres
)) {
2759 WARN("create_nsuri failed: %08x\n", nsres
);
2763 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
2767 static nsresult NSAPI
nsURI_Resolve(nsIFileURL
*iface
, const nsACString
*aRelativePath
,
2768 nsACString
*_retval
)
2770 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2778 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aRelativePath
), _retval
);
2780 if(!ensure_uri(This
))
2781 return NS_ERROR_UNEXPECTED
;
2783 nsACString_GetData(aRelativePath
, &patha
);
2784 path
= heap_strdupUtoW(patha
);
2786 return NS_ERROR_OUT_OF_MEMORY
;
2788 hres
= combine_url(This
->uri
, path
, &new_uri
);
2791 return NS_ERROR_FAILURE
;
2793 hres
= IUri_GetDisplayUri(new_uri
, &ret
);
2794 IUri_Release(new_uri
);
2796 return NS_ERROR_FAILURE
;
2798 reta
= heap_strdupWtoU(ret
);
2801 return NS_ERROR_OUT_OF_MEMORY
;
2803 TRACE("returning %s\n", debugstr_a(reta
));
2804 nsACString_SetData(_retval
, reta
);
2809 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIFileURL
*iface
, nsACString
*aAsciiSpec
)
2811 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2813 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
2815 return nsIFileURL_GetSpec(&This
->nsIFileURL_iface
, aAsciiSpec
);
2818 static nsresult NSAPI
nsURI_GetAsciiHostPort(nsIFileURL
*iface
, nsACString
*aAsciiHostPort
)
2820 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2822 WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This
, aAsciiHostPort
);
2824 return nsIFileURL_GetHostPort(&This
->nsIFileURL_iface
, aAsciiHostPort
);
2827 static nsresult NSAPI
nsURI_GetAsciiHost(nsIFileURL
*iface
, nsACString
*aAsciiHost
)
2829 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2831 WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This
, aAsciiHost
);
2833 return get_uri_string(This
, Uri_PROPERTY_HOST
, aAsciiHost
);
2836 static nsresult NSAPI
nsURI_GetOriginCharset(nsIFileURL
*iface
, nsACString
*aOriginCharset
)
2838 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2840 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
2842 nsACString_SetData(aOriginCharset
, This
->origin_charset
);
2846 static nsresult NSAPI
nsURL_GetRef(nsIFileURL
*iface
, nsACString
*aRef
)
2848 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2853 TRACE("(%p)->(%p)\n", This
, aRef
);
2855 if(!ensure_uri(This
))
2856 return NS_ERROR_UNEXPECTED
;
2858 hres
= IUri_GetFragment(This
->uri
, &ref
);
2860 return NS_ERROR_UNEXPECTED
;
2862 refa
= heap_strdupWtoU(ref
);
2865 return NS_ERROR_OUT_OF_MEMORY
;
2867 nsACString_SetData(aRef
, refa
&& *refa
== '#' ? refa
+1 : refa
);
2872 static nsresult NSAPI
nsURL_SetRef(nsIFileURL
*iface
, const nsACString
*aRef
)
2874 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2879 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRef
));
2881 if(!ensure_uri_builder(This
))
2882 return NS_ERROR_UNEXPECTED
;
2884 nsACString_GetData(aRef
, &refa
);
2885 ref
= heap_strdupUtoW(refa
);
2887 return NS_ERROR_OUT_OF_MEMORY
;
2889 hres
= IUriBuilder_SetFragment(This
->uri_builder
, ref
);
2892 return NS_ERROR_UNEXPECTED
;
2897 static nsresult NSAPI
nsURI_EqualsExceptRef(nsIFileURL
*iface
, nsIURI
*other
, cpp_bool
*_retval
)
2899 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2900 nsWineURI
*other_obj
;
2903 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2905 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2906 if(NS_FAILED(nsres
)) {
2907 TRACE("Could not get nsWineURI interface\n");
2912 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2913 *_retval
= compare_ignoring_frag(This
->uri
, other_obj
->uri
);
2916 nsres
= NS_ERROR_UNEXPECTED
;
2919 nsIFileURL_Release(&other_obj
->nsIFileURL_iface
);
2923 static nsresult NSAPI
nsURI_CloneIgnoreRef(nsIFileURL
*iface
, nsIURI
**_retval
)
2925 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2926 nsWineURI
*wine_uri
;
2930 TRACE("(%p)->(%p)\n", This
, _retval
);
2932 if(!ensure_uri(This
))
2933 return NS_ERROR_UNEXPECTED
;
2935 uri
= get_uri_nofrag(This
->uri
);
2937 return NS_ERROR_FAILURE
;
2939 nsres
= create_nsuri(uri
, This
->window_ref
? This
->window_ref
->window
: NULL
, This
->container
,
2940 This
->origin_charset
, &wine_uri
);
2942 if(NS_FAILED(nsres
)) {
2943 WARN("create_nsuri failed: %08x\n", nsres
);
2947 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
2951 static nsresult NSAPI
nsURI_GetSpecIgnoringRef(nsIFileURL
*iface
, nsACString
*aSpecIgnoringRef
)
2953 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2955 FIXME("(%p)->(%p)\n", This
, aSpecIgnoringRef
);
2957 return nsIFileURL_GetSpec(&This
->nsIFileURL_iface
, aSpecIgnoringRef
);
2960 static nsresult NSAPI
nsURI_GetHasRef(nsIFileURL
*iface
, cpp_bool
*aHasRef
)
2962 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2966 TRACE("(%p)->(%p)\n", This
, aHasRef
);
2968 if(!ensure_uri(This
))
2969 return NS_ERROR_UNEXPECTED
;
2971 hres
= IUri_HasProperty(This
->uri
, Uri_PROPERTY_FRAGMENT
, &b
);
2973 return NS_ERROR_FAILURE
;
2979 static nsresult NSAPI
nsURL_GetFilePath(nsIFileURL
*iface
, nsACString
*aFilePath
)
2981 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2983 TRACE("(%p)->(%p)\n", This
, aFilePath
);
2985 return nsIFileURL_GetPath(&This
->nsIFileURL_iface
, aFilePath
);
2988 static nsresult NSAPI
nsURL_SetFilePath(nsIFileURL
*iface
, const nsACString
*aFilePath
)
2990 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2992 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFilePath
));
2994 if(!This
->is_mutable
)
2995 return NS_ERROR_UNEXPECTED
;
2997 return nsIFileURL_SetPath(&This
->nsIFileURL_iface
, aFilePath
);
3000 static nsresult NSAPI
nsURL_GetQuery(nsIFileURL
*iface
, nsACString
*aQuery
)
3002 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3008 TRACE("(%p)->(%p)\n", This
, aQuery
);
3010 if(!ensure_uri(This
))
3011 return NS_ERROR_UNEXPECTED
;
3013 hres
= IUri_GetQuery(This
->uri
, &query
);
3015 return NS_ERROR_FAILURE
;
3018 if(ptr
&& *ptr
== '?')
3021 nsres
= return_wstr_nsacstr(aQuery
, ptr
, -1);
3022 SysFreeString(query
);
3026 static nsresult NSAPI
nsURL_SetQuery(nsIFileURL
*iface
, const nsACString
*aQuery
)
3028 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3033 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aQuery
));
3035 if(!ensure_uri_builder(This
))
3036 return NS_ERROR_UNEXPECTED
;
3038 nsACString_GetData(aQuery
, &querya
);
3039 query
= heap_strdupUtoW(querya
);
3041 return NS_ERROR_OUT_OF_MEMORY
;
3043 hres
= IUriBuilder_SetQuery(This
->uri_builder
, query
);
3046 return NS_ERROR_UNEXPECTED
;
3051 static nsresult
get_uri_path(nsWineURI
*This
, BSTR
*path
, const WCHAR
**file
, const WCHAR
**ext
)
3056 if(!ensure_uri(This
))
3057 return NS_ERROR_UNEXPECTED
;
3059 hres
= IUri_GetPath(This
->uri
, path
);
3061 return NS_ERROR_FAILURE
;
3063 for(ptr
= *path
+ SysStringLen(*path
)-1; ptr
> *path
&& *ptr
!= '/' && *ptr
!= '\\'; ptr
--);
3064 if(*ptr
== '/' || *ptr
== '\\')
3069 ptr
= strrchrW(ptr
, '.');
3071 ptr
= *path
+ SysStringLen(*path
);
3078 static nsresult NSAPI
nsURL_GetDirectory(nsIFileURL
*iface
, nsACString
*aDirectory
)
3080 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3085 TRACE("(%p)->(%p)\n", This
, aDirectory
);
3087 nsres
= get_uri_path(This
, &path
, &file
, NULL
);
3088 if(NS_FAILED(nsres
))
3091 nsres
= return_wstr_nsacstr(aDirectory
, path
, file
-path
);
3092 SysFreeString(path
);
3096 static nsresult NSAPI
nsURL_SetDirectory(nsIFileURL
*iface
, const nsACString
*aDirectory
)
3098 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3100 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aDirectory
));
3102 /* Not implemented by Gecko */
3103 return NS_ERROR_NOT_IMPLEMENTED
;
3106 static nsresult NSAPI
nsURL_GetFileName(nsIFileURL
*iface
, nsACString
*aFileName
)
3108 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3113 TRACE("(%p)->(%p)\n", This
, aFileName
);
3115 nsres
= get_uri_path(This
, &path
, &file
, NULL
);
3116 if(NS_FAILED(nsres
))
3119 nsres
= return_wstr_nsacstr(aFileName
, file
, -1);
3120 SysFreeString(path
);
3124 static nsresult NSAPI
nsURL_SetFileName(nsIFileURL
*iface
, const nsACString
*aFileName
)
3126 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3127 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileName
));
3128 return NS_ERROR_NOT_IMPLEMENTED
;
3131 static nsresult NSAPI
nsURL_GetFileBaseName(nsIFileURL
*iface
, nsACString
*aFileBaseName
)
3133 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3134 const WCHAR
*file
, *ext
;
3138 TRACE("(%p)->(%p)\n", This
, aFileBaseName
);
3140 nsres
= get_uri_path(This
, &path
, &file
, &ext
);
3141 if(NS_FAILED(nsres
))
3144 nsres
= return_wstr_nsacstr(aFileBaseName
, file
, ext
-file
);
3145 SysFreeString(path
);
3149 static nsresult NSAPI
nsURL_SetFileBaseName(nsIFileURL
*iface
, const nsACString
*aFileBaseName
)
3151 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3152 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileBaseName
));
3153 return NS_ERROR_NOT_IMPLEMENTED
;
3156 static nsresult NSAPI
nsURL_GetFileExtension(nsIFileURL
*iface
, nsACString
*aFileExtension
)
3158 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3160 TRACE("(%p)->(%p)\n", This
, aFileExtension
);
3162 return get_uri_string(This
, Uri_PROPERTY_EXTENSION
, aFileExtension
);
3165 static nsresult NSAPI
nsURL_SetFileExtension(nsIFileURL
*iface
, const nsACString
*aFileExtension
)
3167 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3168 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileExtension
));
3169 return NS_ERROR_NOT_IMPLEMENTED
;
3172 static nsresult NSAPI
nsURL_GetCommonBaseSpec(nsIFileURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
3174 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3175 FIXME("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
3176 return NS_ERROR_NOT_IMPLEMENTED
;
3179 static nsresult NSAPI
nsURL_GetRelativeSpec(nsIFileURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
3181 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3182 FIXME("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
3183 return NS_ERROR_NOT_IMPLEMENTED
;
3186 static nsresult NSAPI
nsFileURL_GetFile(nsIFileURL
*iface
, nsIFile
**aFile
)
3188 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3189 WCHAR path
[MAX_PATH
];
3193 TRACE("(%p)->(%p)\n", This
, aFile
);
3195 hres
= CoInternetParseIUri(This
->uri
, PARSE_PATH_FROM_URL
, 0, path
, sizeof(path
)/sizeof(WCHAR
), &size
, 0);
3197 WARN("CoInternetParseIUri failed: %08x\n", hres
);
3198 return NS_ERROR_FAILURE
;
3201 return create_nsfile(path
, aFile
);
3204 static nsresult NSAPI
nsFileURL_SetFile(nsIFileURL
*iface
, nsIFile
*aFile
)
3206 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3207 FIXME("(%p)->(%p)\n", This
, aFile
);
3208 return NS_ERROR_NOT_IMPLEMENTED
;
3211 static const nsIFileURLVtbl nsFileURLVtbl
= {
3212 nsURI_QueryInterface
,
3239 nsURI_GetAsciiHostPort
,
3241 nsURI_GetOriginCharset
,
3244 nsURI_EqualsExceptRef
,
3245 nsURI_CloneIgnoreRef
,
3246 nsURI_GetSpecIgnoringRef
,
3256 nsURL_GetFileBaseName
,
3257 nsURL_SetFileBaseName
,
3258 nsURL_GetFileExtension
,
3259 nsURL_SetFileExtension
,
3260 nsURL_GetCommonBaseSpec
,
3261 nsURL_GetRelativeSpec
,
3266 static inline nsWineURI
*impl_from_nsIStandardURL(nsIStandardURL
*iface
)
3268 return CONTAINING_RECORD(iface
, nsWineURI
, nsIStandardURL_iface
);
3271 static nsresult NSAPI
nsStandardURL_QueryInterface(nsIStandardURL
*iface
, nsIIDRef riid
,
3274 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3275 return nsIFileURL_QueryInterface(&This
->nsIFileURL_iface
, riid
, result
);
3278 static nsrefcnt NSAPI
nsStandardURL_AddRef(nsIStandardURL
*iface
)
3280 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3281 return nsIFileURL_AddRef(&This
->nsIFileURL_iface
);
3284 static nsrefcnt NSAPI
nsStandardURL_Release(nsIStandardURL
*iface
)
3286 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3287 return nsIFileURL_Release(&This
->nsIFileURL_iface
);
3290 static nsresult NSAPI
nsStandardURL_GetMutable(nsIStandardURL
*iface
, cpp_bool
*aMutable
)
3292 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3294 TRACE("(%p)->(%p)\n", This
, aMutable
);
3296 *aMutable
= This
->is_mutable
;
3300 static nsresult NSAPI
nsStandardURL_SetMutable(nsIStandardURL
*iface
, cpp_bool aMutable
)
3302 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3304 TRACE("(%p)->(%x)\n", This
, aMutable
);
3306 This
->is_mutable
= aMutable
;
3310 static nsresult NSAPI
nsStandardURL_Init(nsIStandardURL
*iface
, UINT32 aUrlType
, LONG aDefaultPort
,
3311 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
)
3313 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3314 FIXME("(%p)->(%d %d %s %s %p)\n", This
, aUrlType
, aDefaultPort
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
), aBaseURI
);
3315 return NS_ERROR_NOT_IMPLEMENTED
;
3318 static const nsIStandardURLVtbl nsStandardURLVtbl
= {
3319 nsStandardURL_QueryInterface
,
3320 nsStandardURL_AddRef
,
3321 nsStandardURL_Release
,
3322 nsStandardURL_GetMutable
,
3323 nsStandardURL_SetMutable
,
3327 static nsresult
create_nsuri(IUri
*iuri
, HTMLOuterWindow
*window
, NSContainer
*container
,
3328 const char *origin_charset
, nsWineURI
**_retval
)
3333 ret
= heap_alloc_zero(sizeof(nsWineURI
));
3335 return NS_ERROR_OUT_OF_MEMORY
;
3337 ret
->nsIFileURL_iface
.lpVtbl
= &nsFileURLVtbl
;
3338 ret
->nsIStandardURL_iface
.lpVtbl
= &nsStandardURLVtbl
;
3340 ret
->is_mutable
= TRUE
;
3342 set_uri_nscontainer(ret
, container
);
3343 set_uri_window(ret
, window
);
3348 hres
= IUri_GetScheme(iuri
, &ret
->scheme
);
3350 ret
->scheme
= URL_SCHEME_UNKNOWN
;
3352 if(origin_charset
&& *origin_charset
&& strcmp(origin_charset
, "UTF-8")) {
3353 ret
->origin_charset
= heap_strdupA(origin_charset
);
3354 if(!ret
->origin_charset
) {
3355 nsIFileURL_Release(&ret
->nsIFileURL_iface
);
3356 return NS_ERROR_OUT_OF_MEMORY
;
3360 TRACE("retval=%p\n", ret
);
3365 HRESULT
create_doc_uri(HTMLOuterWindow
*window
, IUri
*iuri
, nsWineURI
**ret
)
3370 nsres
= create_nsuri(iuri
, window
, window
->doc_obj
->nscontainer
, NULL
, &uri
);
3371 if(NS_FAILED(nsres
))
3374 uri
->is_doc_uri
= TRUE
;
3380 static nsresult
create_nschannel(nsWineURI
*uri
, nsChannel
**ret
)
3384 if(!ensure_uri(uri
))
3385 return NS_ERROR_UNEXPECTED
;
3387 channel
= heap_alloc_zero(sizeof(nsChannel
));
3389 return NS_ERROR_OUT_OF_MEMORY
;
3391 channel
->nsIHttpChannel_iface
.lpVtbl
= &nsChannelVtbl
;
3392 channel
->nsIUploadChannel_iface
.lpVtbl
= &nsUploadChannelVtbl
;
3393 channel
->nsIHttpChannelInternal_iface
.lpVtbl
= &nsHttpChannelInternalVtbl
;
3395 channel
->request_method
= METHOD_GET
;
3396 list_init(&channel
->response_headers
);
3397 list_init(&channel
->request_headers
);
3399 nsIFileURL_AddRef(&uri
->nsIFileURL_iface
);
3406 HRESULT
create_redirect_nschannel(const WCHAR
*url
, nsChannel
*orig_channel
, nsChannel
**ret
)
3408 HTMLOuterWindow
*window
= NULL
;
3415 hres
= create_uri(url
, 0, &iuri
);
3419 if(orig_channel
->uri
->window_ref
)
3420 window
= orig_channel
->uri
->window_ref
->window
;
3421 nsres
= create_nsuri(iuri
, window
, NULL
, NULL
, &uri
);
3423 if(NS_FAILED(nsres
))
3426 nsres
= create_nschannel(uri
, &channel
);
3427 nsIFileURL_Release(&uri
->nsIFileURL_iface
);
3428 if(NS_FAILED(nsres
))
3431 if(orig_channel
->load_group
) {
3432 nsILoadGroup_AddRef(orig_channel
->load_group
);
3433 channel
->load_group
= orig_channel
->load_group
;
3436 if(orig_channel
->notif_callback
) {
3437 nsIInterfaceRequestor_AddRef(orig_channel
->notif_callback
);
3438 channel
->notif_callback
= orig_channel
->notif_callback
;
3441 channel
->load_flags
= orig_channel
->load_flags
| LOAD_REPLACE
;
3443 if(orig_channel
->request_method
== METHOD_POST
)
3444 FIXME("unsupported POST method\n");
3446 if(orig_channel
->original_uri
) {
3447 nsIURI_AddRef(orig_channel
->original_uri
);
3448 channel
->original_uri
= orig_channel
->original_uri
;
3451 if(orig_channel
->referrer
) {
3452 nsIURI_AddRef(orig_channel
->referrer
);
3453 channel
->referrer
= orig_channel
->referrer
;
3461 nsIProtocolHandler nsIProtocolHandler_iface
;
3465 nsIProtocolHandler
*nshandler
;
3466 } nsProtocolHandler
;
3468 static inline nsProtocolHandler
*impl_from_nsIProtocolHandler(nsIProtocolHandler
*iface
)
3470 return CONTAINING_RECORD(iface
, nsProtocolHandler
, nsIProtocolHandler_iface
);
3473 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
3476 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3480 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
3481 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
3482 *result
= &This
->nsIProtocolHandler_iface
;
3483 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
3484 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
3485 *result
= &This
->nsIProtocolHandler_iface
;
3486 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
3487 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
3488 return NS_NOINTERFACE
;
3492 nsISupports_AddRef((nsISupports
*)*result
);
3496 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
3497 return NS_NOINTERFACE
;
3500 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
3502 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3503 LONG ref
= InterlockedIncrement(&This
->ref
);
3505 TRACE("(%p) ref=%d\n", This
, ref
);
3510 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
3512 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3513 LONG ref
= InterlockedDecrement(&This
->ref
);
3515 TRACE("(%p) ref=%d\n", This
, ref
);
3519 nsIProtocolHandler_Release(This
->nshandler
);
3526 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
3528 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3530 TRACE("(%p)->(%p)\n", This
, aScheme
);
3533 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
3534 return NS_ERROR_NOT_IMPLEMENTED
;
3537 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
3540 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3542 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
3545 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
3546 return NS_ERROR_NOT_IMPLEMENTED
;
3549 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
3550 UINT32
*aProtocolFlags
)
3552 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3554 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
3557 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
3558 return NS_ERROR_NOT_IMPLEMENTED
;
3561 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
3562 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3564 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3566 TRACE("((%p)->%s %s %p %p)\n", This
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3570 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
3571 return NS_ERROR_NOT_IMPLEMENTED
;
3574 static nsresult NSAPI
nsProtocolHandler_NewChannel2(nsIProtocolHandler
*iface
,
3575 nsIURI
*aURI
, nsILoadInfo
*aLoadInfo
, nsIChannel
**_retval
)
3577 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3579 TRACE("(%p)->(%p %p %p)\n", This
, aURI
, aLoadInfo
, _retval
);
3582 return nsIProtocolHandler_NewChannel2(This
->nshandler
, aURI
, aLoadInfo
, _retval
);
3583 return NS_ERROR_NOT_IMPLEMENTED
;
3586 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
3587 nsIURI
*aURI
, nsIChannel
**_retval
)
3589 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3591 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
3594 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
3595 return NS_ERROR_NOT_IMPLEMENTED
;
3598 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
3599 LONG port
, const char *scheme
, cpp_bool
*_retval
)
3601 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3603 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
3606 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
3607 return NS_ERROR_NOT_IMPLEMENTED
;
3610 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
3611 nsProtocolHandler_QueryInterface
,
3612 nsProtocolHandler_AddRef
,
3613 nsProtocolHandler_Release
,
3614 nsProtocolHandler_GetScheme
,
3615 nsProtocolHandler_GetDefaultPort
,
3616 nsProtocolHandler_GetProtocolFlags
,
3617 nsProtocolHandler_NewURI
,
3618 nsProtocolHandler_NewChannel2
,
3619 nsProtocolHandler_NewChannel
,
3620 nsProtocolHandler_AllowPort
3623 static nsresult NSAPI
nsIOServiceHook_QueryInterface(nsIIOServiceHook
*iface
, nsIIDRef riid
,
3626 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
3627 TRACE("(IID_nsISupports %p)\n", result
);
3629 }else if(IsEqualGUID(&IID_nsIIOServiceHook
, riid
)) {
3630 TRACE("(IID_nsIIOServiceHook %p)\n", result
);
3633 ERR("(%s %p)\n", debugstr_guid(riid
), result
);
3635 return NS_NOINTERFACE
;
3638 nsISupports_AddRef((nsISupports
*)*result
);
3642 static nsrefcnt NSAPI
nsIOServiceHook_AddRef(nsIIOServiceHook
*iface
)
3647 static nsrefcnt NSAPI
nsIOServiceHook_Release(nsIIOServiceHook
*iface
)
3652 static nsresult NSAPI
nsIOServiceHook_NewChannel(nsIIOServiceHook
*iface
, nsIURI
*aURI
,
3653 nsILoadInfo
*aLoadInfo
, nsIChannel
**_retval
)
3655 nsWineURI
*wine_uri
;
3659 TRACE("(%p %p %p)\n", aURI
, aLoadInfo
, _retval
);
3661 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsWineURI
, (void**)&wine_uri
);
3662 if(NS_FAILED(nsres
)) {
3663 TRACE("Could not get nsWineURI: %08x\n", nsres
);
3664 return NS_SUCCESS_DEFAULT_ACTION
;
3667 nsres
= create_nschannel(wine_uri
, &ret
);
3668 nsIFileURL_Release(&wine_uri
->nsIFileURL_iface
);
3669 if(NS_FAILED(nsres
))
3672 nsIURI_AddRef(aURI
);
3673 ret
->original_uri
= aURI
;
3676 nsIHttpChannel_SetLoadInfo(&ret
->nsIHttpChannel_iface
, aLoadInfo
);
3678 *_retval
= (nsIChannel
*)&ret
->nsIHttpChannel_iface
;
3682 static nsresult NSAPI
nsIOServiceHook_GetProtocolHandler(nsIIOServiceHook
*iface
, nsIProtocolHandler
*aHandler
,
3683 nsIProtocolHandler
**_retval
)
3685 nsIExternalProtocolHandler
*nsexthandler
;
3686 nsProtocolHandler
*ret
;
3689 TRACE("(%p %p)\n", aHandler
, _retval
);
3691 nsres
= nsIProtocolHandler_QueryInterface(aHandler
, &IID_nsIExternalProtocolHandler
, (void**)&nsexthandler
);
3692 if(NS_FAILED(nsres
)) {
3693 nsIProtocolHandler_AddRef(aHandler
);
3694 *_retval
= aHandler
;
3698 nsIExternalProtocolHandler_Release(nsexthandler
);
3700 ret
= heap_alloc(sizeof(nsProtocolHandler
));
3702 return NS_ERROR_OUT_OF_MEMORY
;
3704 ret
->nsIProtocolHandler_iface
.lpVtbl
= &nsProtocolHandlerVtbl
;
3706 nsIProtocolHandler_AddRef(aHandler
);
3707 ret
->nshandler
= aHandler
;
3710 *_retval
= &ret
->nsIProtocolHandler_iface
;
3711 TRACE("return %p\n", *_retval
);
3715 static BOOL
is_gecko_special_uri(const char *spec
)
3717 static const char *special_schemes
[] = {"chrome:", "data:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
3720 for(i
=0; i
< sizeof(special_schemes
)/sizeof(*special_schemes
); i
++) {
3721 if(!strncasecmp(spec
, special_schemes
[i
], strlen(special_schemes
[i
])))
3725 if(!strncasecmp(spec
, "file:", 5)) {
3726 const char *ptr
= spec
+5;
3729 return is_gecko_path(ptr
);
3735 static nsresult NSAPI
nsIOServiceHook_NewURI(nsIIOServiceHook
*iface
, const nsACString
*aSpec
,
3736 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3738 nsWineURI
*wine_uri
, *base_wine_uri
= NULL
;
3739 WCHAR new_spec
[INTERNET_MAX_URL_LENGTH
];
3740 HTMLOuterWindow
*window
= NULL
;
3741 const char *spec
= NULL
;
3747 TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3750 nsACString_GetData(aSpec
, &spec
);
3751 if(is_gecko_special_uri(spec
))
3752 return NS_SUCCESS_DEFAULT_ACTION
;
3754 if(!strncmp(spec
, "wine:", 5))
3758 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsWineURI
, (void**)&base_wine_uri
);
3759 if(NS_SUCCEEDED(nsres
)) {
3760 if(!ensure_uri(base_wine_uri
))
3761 return NS_ERROR_UNEXPECTED
;
3762 if(base_wine_uri
->window_ref
)
3763 window
= base_wine_uri
->window_ref
->window
;
3765 WARN("Could not get base nsWineURI: %08x\n", nsres
);
3769 if(aOriginCharset
&& *aOriginCharset
&& strncasecmp(aOriginCharset
, "utf", 3)) {
3773 len
= MultiByteToWideChar(CP_UTF8
, 0, aOriginCharset
, -1, NULL
, 0);
3774 charset
= SysAllocStringLen(NULL
, len
-1);
3776 return NS_ERROR_OUT_OF_MEMORY
;
3777 MultiByteToWideChar(CP_UTF8
, 0, aOriginCharset
, -1, charset
, len
);
3779 cp
= cp_from_charset_string(charset
);
3781 SysFreeString(charset
);
3784 MultiByteToWideChar(cp
, 0, spec
, -1, new_spec
, sizeof(new_spec
)/sizeof(WCHAR
));
3787 hres
= combine_url(base_wine_uri
->uri
, new_spec
, &urlmon_uri
);
3789 hres
= create_uri(new_spec
, 0, &urlmon_uri
);
3791 WARN("create_uri failed: %08x\n", hres
);
3795 return NS_SUCCESS_DEFAULT_ACTION
;
3797 nsres
= create_nsuri(urlmon_uri
, window
, NULL
, NULL
, &wine_uri
);
3798 IUri_Release(urlmon_uri
);
3800 nsIFileURL_Release(&base_wine_uri
->nsIFileURL_iface
);
3801 if(NS_FAILED(nsres
))
3804 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
3808 static const char *debugstr_protocol_flags(UINT32 flags
)
3811 #define X(f) case f: return #f
3816 X(ALLOWS_PROXY_HTTP
);
3817 X(URI_INHERITS_SECURITY_CONTEXT
);
3818 X(URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT
);
3819 X(URI_LOADABLE_BY_ANYONE
);
3820 X(URI_DANGEROUS_TO_LOAD
);
3821 X(URI_IS_UI_RESOURCE
);
3822 X(URI_IS_LOCAL_FILE
);
3823 X(URI_LOADABLE_BY_SUBSUMERS
);
3824 X(URI_DOES_NOT_RETURN_DATA
);
3825 X(URI_IS_LOCAL_RESOURCE
);
3826 X(URI_OPENING_EXECUTES_SCRIPT
);
3827 X(URI_NON_PERSISTABLE
);
3828 X(URI_FORBIDS_COOKIE_ACCESS
);
3829 X(URI_CROSS_ORIGIN_NEEDS_WEBAPPS_PERM
);
3830 X(URI_SYNC_LOAD_IS_OK
);
3831 X(URI_SAFE_TO_LOAD_IN_SECURE_CONTEXT
);
3832 X(URI_FETCHABLE_BY_ANYONE
);
3835 return wine_dbg_sprintf("%08x", flags
);
3839 static nsresult NSAPI
nsIOServiceHook_ProtocolHasFlags(nsIIOServiceHook
*iface
, nsIURI
*aURI
, UINT32 aFlags
, cpp_bool
*_retval
)
3841 TRACE("(%p %s %p)\n", aURI
, debugstr_protocol_flags(aFlags
), _retval
);
3842 return NS_SUCCESS_DEFAULT_ACTION
;
3845 static nsresult NSAPI
nsIOServiceHook_URIChainHasFlags(nsIIOServiceHook
*iface
, nsIURI
*aURI
, UINT32 aFlags
, cpp_bool
*_retval
)
3847 TRACE("(%p %s %p)\n", aURI
, debugstr_protocol_flags(aFlags
), _retval
);
3849 if(aFlags
== URI_DOES_NOT_RETURN_DATA
) {
3854 return NS_SUCCESS_DEFAULT_ACTION
;
3857 static const nsIIOServiceHookVtbl nsIOServiceHookVtbl
= {
3858 nsIOServiceHook_QueryInterface
,
3859 nsIOServiceHook_AddRef
,
3860 nsIOServiceHook_Release
,
3861 nsIOServiceHook_NewChannel
,
3862 nsIOServiceHook_GetProtocolHandler
,
3863 nsIOServiceHook_NewURI
,
3864 nsIOServiceHook_ProtocolHasFlags
,
3865 nsIOServiceHook_URIChainHasFlags
3868 static nsIIOServiceHook nsIOServiceHook
= { &nsIOServiceHookVtbl
};
3870 static BOOL
translate_url(HTMLDocumentObj
*doc
, nsWineURI
*uri
)
3872 OLECHAR
*new_url
= NULL
;
3877 if(!doc
->hostui
|| !ensure_uri(uri
))
3880 hres
= IUri_GetDisplayUri(uri
->uri
, &url
);
3884 hres
= IDocHostUIHandler_TranslateUrl(doc
->hostui
, 0, url
, &new_url
);
3885 if(hres
== S_OK
&& new_url
) {
3886 if(strcmpW(url
, new_url
)) {
3887 FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url
), debugstr_w(new_url
));
3890 CoTaskMemFree(new_url
);
3897 nsresult
on_start_uri_open(NSContainer
*nscontainer
, nsIURI
*uri
, cpp_bool
*_retval
)
3899 nsWineURI
*wine_uri
;
3904 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
3905 if(NS_FAILED(nsres
)) {
3906 WARN("Could not get nsWineURI: %08x\n", nsres
);
3907 return NS_ERROR_NOT_IMPLEMENTED
;
3910 if(!wine_uri
->is_doc_uri
) {
3911 wine_uri
->is_doc_uri
= TRUE
;
3913 if(!wine_uri
->container
) {
3914 nsIWebBrowserChrome_AddRef(&nscontainer
->nsIWebBrowserChrome_iface
);
3915 wine_uri
->container
= nscontainer
;
3918 if(nscontainer
->doc
)
3919 *_retval
= translate_url(nscontainer
->doc
, wine_uri
);
3922 nsIFileURL_Release(&wine_uri
->nsIFileURL_iface
);
3926 void init_nsio(nsIComponentManager
*component_manager
)
3928 nsIFactory
*old_factory
= NULL
;
3931 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
3932 &IID_nsIFactory
, (void**)&old_factory
);
3933 if(NS_FAILED(nsres
)) {
3934 ERR("Could not get factory: %08x\n", nsres
);
3938 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
3939 if(NS_FAILED(nsres
)) {
3940 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
3941 nsIFactory_Release(old_factory
);
3945 nsres
= nsIIOService_SetHook(nsio
, &nsIOServiceHook
);
3946 assert(nsres
== NS_OK
);
3949 void release_nsio(void)
3952 nsIIOService_Release(nsio
);