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
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 #define NS_IOSERVICE_CLASSNAME "nsIOService"
42 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
44 static const IID NS_IOSERVICE_CID
=
45 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
46 static const IID IID_nsWineURI
=
47 {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
49 static nsIIOService
*nsio
= NULL
;
51 static const char *request_method_strings
[] = {"GET", "PUT", "POST"};
54 nsIFileURL nsIFileURL_iface
; /* For non-file URL objects, it's just nsIURL */
55 nsIStandardURL nsIStandardURL_iface
;
59 nsChannelBSC
*channel_bsc
;
61 IUriBuilder
*uri_builder
;
66 static BOOL
ensure_uri(nsWineURI
*This
)
70 assert(This
->uri
|| This
->uri_builder
);
73 hres
= IUriBuilder_CreateUriSimple(This
->uri_builder
, 0, 0, &This
->uri
);
75 WARN("CreateUriSimple failed: %08x\n", hres
);
83 IUri
*nsuri_get_uri(nsWineURI
*nsuri
)
85 if(!ensure_uri(nsuri
))
88 IUri_AddRef(nsuri
->uri
);
92 IUri
*get_uri_nofrag(IUri
*uri
)
94 IUriBuilder
*uri_builder
;
99 hres
= IUri_HasProperty(uri
, Uri_PROPERTY_FRAGMENT
, &b
);
100 if(SUCCEEDED(hres
) && !b
) {
105 hres
= CreateIUriBuilder(uri
, 0, 0, &uri_builder
);
109 hres
= IUriBuilder_RemoveProperties(uri_builder
, Uri_HAS_FRAGMENT
);
111 hres
= IUriBuilder_CreateUriSimple(uri_builder
, 0, 0, &ret
);
112 IUriBuilder_Release(uri_builder
);
119 static BOOL
compare_ignoring_frag(IUri
*uri1
, IUri
*uri2
)
121 IUri
*uri_nofrag1
, *uri_nofrag2
;
124 uri_nofrag1
= get_uri_nofrag(uri1
);
128 uri_nofrag2
= get_uri_nofrag(uri2
);
130 IUri_IsEqual(uri_nofrag1
, uri_nofrag2
, &ret
);
131 IUri_Release(uri_nofrag2
);
134 IUri_Release(uri_nofrag1
);
138 static HRESULT
combine_url(IUri
*base_uri
, const WCHAR
*rel_url
, IUri
**ret
)
143 uri_nofrag
= get_uri_nofrag(base_uri
);
147 hres
= CoInternetCombineUrlEx(uri_nofrag
, rel_url
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
149 IUri_Release(uri_nofrag
);
151 WARN("CoInternetCombineUrlEx failed: %08x\n", hres
);
155 static nsresult
create_nsuri(IUri
*,nsWineURI
**);
157 static const char *debugstr_nsacstr(const nsACString
*nsstr
)
161 nsACString_GetData(nsstr
, &data
);
162 return debugstr_a(data
);
165 static nsresult
return_wstr_nsacstr(nsACString
*ret_str
, const WCHAR
*str
, int len
)
170 TRACE("returning %s\n", debugstr_wn(str
, len
));
173 nsACString_SetData(ret_str
, "");
177 lena
= WideCharToMultiByte(CP_UTF8
, 0, str
, len
, NULL
, 0, NULL
, NULL
);
178 stra
= heap_alloc(lena
+1);
180 return NS_ERROR_OUT_OF_MEMORY
;
182 WideCharToMultiByte(CP_UTF8
, 0, str
, len
, stra
, lena
, NULL
, NULL
);
185 nsACString_SetData(ret_str
, stra
);
190 HRESULT
nsuri_to_url(LPCWSTR nsuri
, BOOL ret_empty
, BSTR
*ret
)
192 const WCHAR
*ptr
= nsuri
;
194 static const WCHAR wine_prefixW
[] = {'w','i','n','e',':'};
196 if(!wcsncmp(nsuri
, wine_prefixW
, ARRAY_SIZE(wine_prefixW
)))
197 ptr
+= ARRAY_SIZE(wine_prefixW
);
199 if(*ptr
|| ret_empty
) {
200 *ret
= SysAllocString(ptr
);
202 return E_OUTOFMEMORY
;
207 TRACE("%s -> %s\n", debugstr_w(nsuri
), debugstr_w(*ret
));
211 static BOOL
exec_shldocvw_67(HTMLDocumentObj
*doc
, BSTR url
)
213 IOleCommandTarget
*cmdtrg
= NULL
;
216 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
217 if(SUCCEEDED(hres
)) {
218 VARIANT varUrl
, varRes
;
220 V_VT(&varUrl
) = VT_BSTR
;
221 V_BSTR(&varUrl
) = url
;
222 V_VT(&varRes
) = VT_BOOL
;
224 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
226 IOleCommandTarget_Release(cmdtrg
);
228 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
229 TRACE("got VARIANT_FALSE, do not load\n");
237 static nsresult
before_async_open(nsChannel
*channel
, GeckoBrowser
*container
, BOOL
*cancel
)
239 HTMLDocumentObj
*doc
= container
->doc
;
248 hres
= IUri_GetDisplayUri(channel
->uri
->uri
, &display_uri
);
250 return NS_ERROR_FAILURE
;
254 hres
= IDocHostUIHandler_TranslateUrl(doc
->hostui
, 0, display_uri
, &new_url
);
255 if(hres
== S_OK
&& new_url
) {
256 if(wcscmp(display_uri
, new_url
)) {
257 FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(display_uri
), debugstr_w(new_url
));
258 CoTaskMemFree(new_url
);
262 CoTaskMemFree(new_url
);
266 if(!exec_shldocvw_67(doc
, display_uri
)) {
267 SysFreeString(display_uri
);
272 hres
= hlink_frame_navigate(&doc
->basedoc
, display_uri
, channel
, 0, cancel
);
273 SysFreeString(display_uri
);
279 HRESULT
load_nsuri(HTMLOuterWindow
*window
, nsWineURI
*uri
, nsIInputStream
*post_stream
,
280 nsChannelBSC
*channelbsc
, DWORD flags
)
282 nsIWebNavigation
*web_navigation
;
283 nsIDocShellLoadInfo
*load_info
;
284 nsIDocShell
*doc_shell
;
285 HTMLDocumentNode
*doc
;
288 nsres
= get_nsinterface((nsISupports
*)window
->nswindow
, &IID_nsIWebNavigation
, (void**)&web_navigation
);
289 if(NS_FAILED(nsres
)) {
290 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
294 nsres
= nsIWebNavigation_QueryInterface(web_navigation
, &IID_nsIDocShell
, (void**)&doc_shell
);
295 nsIWebNavigation_Release(web_navigation
);
296 if(NS_FAILED(nsres
)) {
297 ERR("Could not get nsIDocShell: %08x\n", nsres
);
301 nsres
= nsIDocShell_CreateLoadInfo(doc_shell
, &load_info
);
302 if(NS_FAILED(nsres
)) {
303 nsIDocShell_Release(doc_shell
);
307 nsres
= nsIDocShellLoadInfo_SetLoadType(load_info
, (flags
& LOAD_FLAGS_BYPASS_CACHE
) ? loadNormalBypassCache
: loadNormal
);
308 assert(nsres
== NS_OK
);
311 nsres
= nsIDocShellLoadInfo_SetPostDataStream(load_info
, post_stream
);
312 assert(nsres
== NS_OK
);
315 if(window
->uri_nofrag
) {
316 nsWineURI
*referrer_uri
;
317 nsres
= create_nsuri(window
->uri_nofrag
, &referrer_uri
);
318 if(NS_SUCCEEDED(nsres
)) {
319 nsres
= nsIDocShellLoadInfo_SetReferrer(load_info
, (nsIURI
*)&referrer_uri
->nsIFileURL_iface
);
320 assert(nsres
== NS_OK
);
321 nsIFileURL_Release(&referrer_uri
->nsIFileURL_iface
);
325 uri
->channel_bsc
= channelbsc
;
326 doc
= window
->base
.inner_window
->doc
;
327 doc
->skip_mutation_notif
= TRUE
;
328 nsres
= nsIDocShell_LoadURI(doc_shell
, (nsIURI
*)&uri
->nsIFileURL_iface
, load_info
, flags
, FALSE
);
329 if(doc
== window
->base
.inner_window
->doc
)
330 doc
->skip_mutation_notif
= FALSE
;
331 uri
->channel_bsc
= NULL
;
332 nsIDocShell_Release(doc_shell
);
333 nsIDocShellLoadInfo_Release(load_info
);
334 if(NS_FAILED(nsres
)) {
335 WARN("LoadURI failed: %08x\n", nsres
);
342 static inline BOOL
is_http_channel(nsChannel
*This
)
344 return This
->uri
->scheme
== URL_SCHEME_HTTP
|| This
->uri
->scheme
== URL_SCHEME_HTTPS
;
347 static http_header_t
*find_http_header(struct list
*headers
, const WCHAR
*name
, int len
)
351 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
352 if(!wcsnicmp(iter
->header
, name
, len
) && !iter
->header
[len
])
359 static nsresult
get_channel_http_header(struct list
*headers
, const nsACString
*header_name_str
,
362 const char *header_namea
;
363 http_header_t
*header
;
367 nsACString_GetData(header_name_str
, &header_namea
);
368 header_name
= heap_strdupAtoW(header_namea
);
370 return NS_ERROR_UNEXPECTED
;
372 header
= find_http_header(headers
, header_name
, lstrlenW(header_name
));
373 heap_free(header_name
);
375 return NS_ERROR_NOT_AVAILABLE
;
377 data
= heap_strdupWtoA(header
->data
);
379 return NS_ERROR_UNEXPECTED
;
381 TRACE("%s -> %s\n", debugstr_a(header_namea
), debugstr_a(data
));
382 nsACString_SetData(_retval
, data
);
387 HRESULT
set_http_header(struct list
*headers
, const WCHAR
*name
, int name_len
,
388 const WCHAR
*value
, int value_len
)
390 http_header_t
*header
;
392 TRACE("%s: %s\n", debugstr_wn(name
, name_len
), debugstr_wn(value
, value_len
));
394 header
= find_http_header(headers
, name
, name_len
);
398 new_data
= heap_strndupW(value
, value_len
);
400 return E_OUTOFMEMORY
;
402 heap_free(header
->data
);
403 header
->data
= new_data
;
405 header
= heap_alloc(sizeof(http_header_t
));
407 return E_OUTOFMEMORY
;
409 header
->header
= heap_strndupW(name
, name_len
);
410 header
->data
= heap_strndupW(value
, value_len
);
411 if(!header
->header
|| !header
->data
) {
412 heap_free(header
->header
);
413 heap_free(header
->data
);
415 return E_OUTOFMEMORY
;
418 list_add_tail(headers
, &header
->entry
);
424 static nsresult
set_channel_http_header(struct list
*headers
, const nsACString
*name_str
,
425 const nsACString
*value_str
)
427 const char *namea
, *valuea
;
431 nsACString_GetData(name_str
, &namea
);
432 name
= heap_strdupAtoW(namea
);
434 return NS_ERROR_UNEXPECTED
;
436 nsACString_GetData(value_str
, &valuea
);
437 value
= heap_strdupAtoW(valuea
);
440 return NS_ERROR_UNEXPECTED
;
443 hres
= set_http_header(headers
, name
, lstrlenW(name
), value
, lstrlenW(value
));
447 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_UNEXPECTED
;
450 static nsresult
visit_http_headers(struct list
*headers
, nsIHttpHeaderVisitor
*visitor
)
452 nsACString header_str
, value_str
;
453 char *header
, *value
;
457 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
458 header
= heap_strdupWtoA(iter
->header
);
460 return NS_ERROR_OUT_OF_MEMORY
;
462 value
= heap_strdupWtoA(iter
->data
);
465 return NS_ERROR_OUT_OF_MEMORY
;
468 nsACString_InitDepend(&header_str
, header
);
469 nsACString_InitDepend(&value_str
, value
);
470 nsres
= nsIHttpHeaderVisitor_VisitHeader(visitor
, &header_str
, &value_str
);
471 nsACString_Finish(&header_str
);
472 nsACString_Finish(&value_str
);
482 static void free_http_headers(struct list
*list
)
484 http_header_t
*iter
, *iter_next
;
486 LIST_FOR_EACH_ENTRY_SAFE(iter
, iter_next
, list
, http_header_t
, entry
) {
487 list_remove(&iter
->entry
);
488 heap_free(iter
->header
);
489 heap_free(iter
->data
);
494 static inline nsChannel
*impl_from_nsIHttpChannel(nsIHttpChannel
*iface
)
496 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannel_iface
);
499 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, void **result
)
501 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
503 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
504 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
505 *result
= &This
->nsIHttpChannel_iface
;
506 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
507 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
508 *result
= &This
->nsIHttpChannel_iface
;
509 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
510 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
511 *result
= &This
->nsIHttpChannel_iface
;
512 }else if(IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
513 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
514 *result
= is_http_channel(This
) ? &This
->nsIHttpChannel_iface
: NULL
;
515 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
516 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
517 *result
= &This
->nsIUploadChannel_iface
;
518 }else if(IsEqualGUID(&IID_nsIFormPOSTActionChannel
, riid
)) {
519 TRACE("(%p)->(IID_nsIFormPOSTActionChannel %p)\n", This
, result
);
520 *result
= &This
->nsIUploadChannel_iface
;
521 }else if(IsEqualGUID(&IID_nsIHttpChannelInternal
, riid
)) {
522 TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This
, result
);
523 *result
= is_http_channel(This
) ? &This
->nsIHttpChannelInternal_iface
: NULL
;
525 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
530 nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
534 return NS_NOINTERFACE
;
537 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
539 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
540 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
542 TRACE("(%p) ref=%d\n", This
, ref
);
547 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
549 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
550 LONG ref
= InterlockedDecrement(&This
->ref
);
553 nsIFileURL_Release(&This
->uri
->nsIFileURL_iface
);
555 nsISupports_Release(This
->owner
);
556 if(This
->post_data_stream
)
557 nsIInputStream_Release(This
->post_data_stream
);
559 nsILoadGroup_Release(This
->load_group
);
560 if(This
->notif_callback
)
561 nsIInterfaceRequestor_Release(This
->notif_callback
);
562 if(This
->original_uri
)
563 nsIURI_Release(This
->original_uri
);
565 nsIURI_Release(This
->referrer
);
567 free_http_headers(&This
->response_headers
);
568 free_http_headers(&This
->request_headers
);
570 heap_free(This
->content_type
);
571 heap_free(This
->charset
);
578 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
580 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
582 TRACE("(%p)->(%p)\n", This
, aName
);
584 return nsIFileURL_GetSpec(&This
->uri
->nsIFileURL_iface
, aName
);
587 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
589 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
591 FIXME("(%p)->(%p)\n", This
, _retval
);
593 return NS_ERROR_NOT_IMPLEMENTED
;
596 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
598 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
600 WARN("(%p)->(%p) returning NS_OK\n", This
, aStatus
);
602 return *aStatus
= NS_OK
;
605 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
607 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
609 TRACE("(%p)->(%08x)\n", This
, aStatus
);
611 if(This
->binding
&& This
->binding
->bsc
.binding
)
612 IBinding_Abort(This
->binding
->bsc
.binding
);
614 WARN("No binding to cancel\n");
618 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
620 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
622 FIXME("(%p)\n", This
);
624 return NS_ERROR_NOT_IMPLEMENTED
;
627 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
629 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
631 FIXME("(%p)\n", This
);
633 return NS_ERROR_NOT_IMPLEMENTED
;
636 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
638 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
640 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
643 nsILoadGroup_AddRef(This
->load_group
);
645 *aLoadGroup
= This
->load_group
;
649 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
651 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
653 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
656 nsILoadGroup_Release(This
->load_group
);
658 nsILoadGroup_AddRef(aLoadGroup
);
659 This
->load_group
= aLoadGroup
;
664 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
666 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
668 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
670 *aLoadFlags
= This
->load_flags
;
674 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
676 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
678 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
680 This
->load_flags
= aLoadFlags
;
684 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
686 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
688 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
690 if(This
->original_uri
)
691 nsIURI_AddRef(This
->original_uri
);
693 *aOriginalURI
= This
->original_uri
;
697 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
699 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
701 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
703 if(This
->original_uri
)
704 nsIURI_Release(This
->original_uri
);
706 nsIURI_AddRef(aOriginalURI
);
707 This
->original_uri
= aOriginalURI
;
711 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
713 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
715 TRACE("(%p)->(%p)\n", This
, aURI
);
717 nsIFileURL_AddRef(&This
->uri
->nsIFileURL_iface
);
718 *aURI
= (nsIURI
*)&This
->uri
->nsIFileURL_iface
;
723 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
725 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
727 TRACE("(%p)->(%p)\n", This
, aOwner
);
730 nsISupports_AddRef(This
->owner
);
731 *aOwner
= This
->owner
;
736 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
738 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
740 TRACE("(%p)->(%p)\n", This
, aOwner
);
743 nsISupports_AddRef(aOwner
);
745 nsISupports_Release(This
->owner
);
746 This
->owner
= aOwner
;
751 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
752 nsIInterfaceRequestor
**aNotificationCallbacks
)
754 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
756 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
758 if(This
->notif_callback
)
759 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
760 *aNotificationCallbacks
= This
->notif_callback
;
765 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
766 nsIInterfaceRequestor
*aNotificationCallbacks
)
768 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
770 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
772 if(This
->notif_callback
)
773 nsIInterfaceRequestor_Release(This
->notif_callback
);
774 if(aNotificationCallbacks
)
775 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
777 This
->notif_callback
= aNotificationCallbacks
;
782 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
784 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
786 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
788 return NS_ERROR_NOT_IMPLEMENTED
;
791 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
793 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
795 TRACE("(%p)->(%p)\n", This
, aContentType
);
797 if(This
->content_type
) {
798 nsACString_SetData(aContentType
, This
->content_type
);
802 if(This
->load_flags
& LOAD_DOCUMENT_URI
) {
803 WARN("Document channel with no MIME set. Assuming text/html\n");
804 nsACString_SetData(aContentType
, "text/html");
808 WARN("unknown type\n");
809 return NS_ERROR_FAILURE
;
812 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
813 const nsACString
*aContentType
)
815 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
816 const char *content_type
;
818 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentType
));
820 nsACString_GetData(aContentType
, &content_type
);
821 heap_free(This
->content_type
);
822 This
->content_type
= heap_strdupA(content_type
);
827 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
828 nsACString
*aContentCharset
)
830 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
832 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
835 nsACString_SetData(aContentCharset
, This
->charset
);
839 nsACString_SetData(aContentCharset
, "");
843 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
844 const nsACString
*aContentCharset
)
846 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
850 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentCharset
));
852 nsACString_GetData(aContentCharset
, &data
);
853 charset
= heap_strdupA(data
);
855 return NS_ERROR_OUT_OF_MEMORY
;
857 heap_free(This
->charset
);
858 This
->charset
= charset
;
862 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, INT64
*aContentLength
)
864 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
866 FIXME("(%p)->(%p)\n", This
, aContentLength
);
868 return NS_ERROR_NOT_IMPLEMENTED
;
871 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, INT64 aContentLength
)
873 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
875 FIXME("(%p)->(%s)\n", This
, wine_dbgstr_longlong(aContentLength
));
877 return NS_ERROR_NOT_IMPLEMENTED
;
880 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
882 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
884 FIXME("(%p)->(%p)\n", This
, _retval
);
886 return NS_ERROR_NOT_IMPLEMENTED
;
889 static nsresult NSAPI
nsChannel_Open2(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
891 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
893 FIXME("(%p)->(%p)\n", This
, _retval
);
895 return NS_ERROR_NOT_IMPLEMENTED
;
898 static HTMLOuterWindow
*get_channel_window(nsChannel
*This
)
900 nsIWebProgress
*web_progress
= NULL
;
901 mozIDOMWindowProxy
*mozwindow
;
902 HTMLOuterWindow
*window
;
905 if(This
->load_group
) {
906 nsIRequestObserver
*req_observer
;
908 nsres
= nsILoadGroup_GetGroupObserver(This
->load_group
, &req_observer
);
909 if(NS_FAILED(nsres
)) {
910 ERR("GetGroupObserver failed: %08x\n", nsres
);
915 nsres
= nsIRequestObserver_QueryInterface(req_observer
, &IID_nsIWebProgress
, (void**)&web_progress
);
916 nsIRequestObserver_Release(req_observer
);
917 if(NS_FAILED(nsres
)) {
918 ERR("Could not get nsIWebProgress iface: %08x\n", nsres
);
924 if(!web_progress
&& This
->notif_callback
) {
925 nsres
= nsIInterfaceRequestor_GetInterface(This
->notif_callback
, &IID_nsIWebProgress
, (void**)&web_progress
);
926 if(NS_FAILED(nsres
)) {
927 ERR("GetInterface(IID_nsIWebProgress failed: %08x\n", nsres
);
933 ERR("Could not find nsIWebProgress\n");
937 nsres
= nsIWebProgress_GetDOMWindow(web_progress
, &mozwindow
);
938 nsIWebProgress_Release(web_progress
);
939 if(NS_FAILED(nsres
) || !mozwindow
) {
940 ERR("GetDOMWindow failed: %08x\n", nsres
);
944 window
= mozwindow_to_window(mozwindow
);
945 mozIDOMWindowProxy_Release(mozwindow
);
948 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
950 FIXME("NULL window for %p\n", mozwindow
);
956 HTMLInnerWindow
*window
;
957 nsChannelBSC
*bscallback
;
958 } start_binding_task_t
;
960 static void start_binding_proc(task_t
*_task
)
962 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
964 start_binding(task
->window
, (BSCallback
*)task
->bscallback
, NULL
);
967 static void start_binding_task_destr(task_t
*_task
)
969 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
971 IBindStatusCallback_Release(&task
->bscallback
->bsc
.IBindStatusCallback_iface
);
975 static nsresult
async_open(nsChannel
*This
, HTMLOuterWindow
*window
, BOOL is_doc_channel
, nsIStreamListener
*listener
,
976 nsISupports
*context
)
978 nsChannelBSC
*bscallback
;
979 IMoniker
*mon
= NULL
;
982 hres
= CreateURLMonikerEx2(NULL
, This
->uri
->uri
, &mon
, 0);
984 WARN("CreateURLMoniker failed: %08x\n", hres
);
985 return NS_ERROR_UNEXPECTED
;
989 set_current_mon(window
, mon
, BINDING_NAVIGATED
);
991 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, is_doc_channel
, &bscallback
);
992 IMoniker_Release(mon
);
994 return NS_ERROR_UNEXPECTED
;
996 channelbsc_set_channel(bscallback
, This
, listener
, context
);
999 hres
= create_pending_window(window
, bscallback
);
1001 async_start_doc_binding(window
, window
->pending_window
);
1002 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
1004 return NS_ERROR_UNEXPECTED
;
1006 start_binding_task_t
*task
;
1008 task
= heap_alloc(sizeof(start_binding_task_t
));
1010 IBindStatusCallback_Release(&bscallback
->bsc
.IBindStatusCallback_iface
);
1011 return NS_ERROR_OUT_OF_MEMORY
;
1014 task
->window
= window
->base
.inner_window
;
1015 task
->bscallback
= bscallback
;
1016 hres
= push_task(&task
->header
, start_binding_proc
, start_binding_task_destr
, window
->base
.inner_window
->task_magic
);
1018 return NS_ERROR_OUT_OF_MEMORY
;
1024 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
1025 nsISupports
*aContext
)
1027 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1028 HTMLOuterWindow
*window
= NULL
;
1029 BOOL is_document_channel
;
1030 BOOL cancel
= FALSE
;
1031 nsresult nsres
= NS_OK
;
1033 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
1035 if(!ensure_uri(This
->uri
))
1036 return NS_ERROR_FAILURE
;
1038 if(TRACE_ON(mshtml
)) {
1042 hres
= IUri_GetDisplayUri(This
->uri
->uri
, &uri_str
);
1043 if(SUCCEEDED(hres
)) {
1044 TRACE("opening %s\n", debugstr_w(uri_str
));
1045 SysFreeString(uri_str
);
1047 WARN("GetDisplayUri failed: %08x\n", hres
);
1051 window
= get_channel_window(This
);
1053 ERR("window = NULL\n");
1054 return NS_ERROR_UNEXPECTED
;
1057 is_document_channel
= !!(This
->load_flags
& LOAD_DOCUMENT_URI
);
1059 if(is_document_channel
) {
1060 if(This
->uri
->channel_bsc
) {
1061 channelbsc_set_channel(This
->uri
->channel_bsc
, This
, aListener
, aContext
);
1065 if(is_main_content_window(window
)) {
1066 if(!This
->uri
->channel_bsc
) {
1067 /* top window navigation initiated by Gecko */
1068 nsres
= before_async_open(This
, window
->browser
, &cancel
);
1069 if(NS_SUCCEEDED(nsres
) && cancel
) {
1070 TRACE("canceled\n");
1071 nsres
= NS_BINDING_ABORTED
;
1073 }else if(window
->browser
->doc
->mime
) {
1074 heap_free(This
->content_type
);
1075 This
->content_type
= heap_strdupWtoA(window
->browser
->doc
->mime
);
1081 nsres
= async_open(This
, window
, is_document_channel
, aListener
, aContext
);
1083 if(NS_SUCCEEDED(nsres
) && This
->load_group
) {
1084 nsres
= nsILoadGroup_AddRequest(This
->load_group
, (nsIRequest
*)&This
->nsIHttpChannel_iface
,
1086 if(NS_FAILED(nsres
))
1087 ERR("AddRequest failed: %08x\n", nsres
);
1090 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
1094 static nsresult NSAPI
nsChannel_AsyncOpen2(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
)
1096 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1097 FIXME("(%p)->(%p)\n", This
, aListener
);
1098 return nsIHttpChannel_AsyncOpen(&This
->nsIHttpChannel_iface
, aListener
, NULL
);
1101 static nsresult NSAPI
nsChannel_GetContentDisposition(nsIHttpChannel
*iface
, UINT32
*aContentDisposition
)
1103 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1104 TRACE("(%p)->(%p) unimplemented\n", This
, aContentDisposition
);
1105 return NS_ERROR_NOT_IMPLEMENTED
;
1108 static nsresult NSAPI
nsChannel_SetContentDisposition(nsIHttpChannel
*iface
, UINT32 aContentDisposition
)
1110 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1111 FIXME("(%p)->(%u)\n", This
, aContentDisposition
);
1112 return NS_ERROR_NOT_IMPLEMENTED
;
1115 static nsresult NSAPI
nsChannel_GetContentDispositionFilename(nsIHttpChannel
*iface
, nsAString
*aContentDispositionFilename
)
1117 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1118 FIXME("(%p)->(%p)\n", This
, aContentDispositionFilename
);
1119 return NS_ERROR_NOT_IMPLEMENTED
;
1122 static nsresult NSAPI
nsChannel_SetContentDispositionFilename(nsIHttpChannel
*iface
, const nsAString
*aContentDispositionFilename
)
1124 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1125 FIXME("(%p)->(%p)\n", This
, aContentDispositionFilename
);
1126 return NS_ERROR_NOT_IMPLEMENTED
;
1129 static nsresult NSAPI
nsChannel_GetContentDispositionHeader(nsIHttpChannel
*iface
, nsACString
*aContentDispositionHeader
)
1131 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1132 TRACE("(%p)->(%p) unimplemented\n", This
, aContentDispositionHeader
);
1133 return NS_ERROR_NOT_IMPLEMENTED
;
1136 static nsresult NSAPI
nsChannel_GetLoadInfo(nsIHttpChannel
*iface
, nsILoadInfo
**aLoadInfo
)
1138 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1140 TRACE("(%p)->(%p)\n", This
, aLoadInfo
);
1143 nsISupports_AddRef(This
->load_info
);
1144 *aLoadInfo
= This
->load_info
;
1148 static nsresult NSAPI
nsChannel_SetLoadInfo(nsIHttpChannel
*iface
, nsILoadInfo
*aLoadInfo
)
1150 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1152 TRACE("(%p)->(%p)\n", This
, aLoadInfo
);
1155 nsISupports_Release(This
->load_info
);
1156 This
->load_info
= aLoadInfo
;
1158 nsISupports_AddRef(This
->load_info
);
1162 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
1164 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1166 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
1168 nsACString_SetData(aRequestMethod
, request_method_strings
[This
->request_method
]);
1172 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
1173 const nsACString
*aRequestMethod
)
1175 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1179 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRequestMethod
));
1181 nsACString_GetData(aRequestMethod
, &method
);
1182 for(i
=0; i
< ARRAY_SIZE(request_method_strings
); i
++) {
1183 if(!stricmp(method
, request_method_strings
[i
])) {
1184 This
->request_method
= i
;
1189 ERR("Invalid method %s\n", debugstr_a(method
));
1190 return NS_ERROR_UNEXPECTED
;
1193 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
1195 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1197 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1200 nsIURI_AddRef(This
->referrer
);
1201 *aReferrer
= This
->referrer
;
1205 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
1207 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1209 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1211 return nsIHttpChannel_SetReferrerWithPolicy(&This
->nsIHttpChannel_iface
, aReferrer
, 0);
1214 static nsresult NSAPI
nsChannel_GetReferrerPolicy(nsIHttpChannel
*iface
, UINT32
*aReferrerPolicy
)
1216 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1217 TRACE("(%p)->(%p) unimplemented\n", This
, aReferrerPolicy
);
1218 return NS_ERROR_NOT_IMPLEMENTED
;
1221 static nsresult NSAPI
nsChannel_SetReferrerWithPolicy(nsIHttpChannel
*iface
, nsIURI
*aReferrer
, UINT32 aReferrerPolicy
)
1223 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1224 DWORD channel_scheme
, referrer_scheme
;
1225 nsWineURI
*referrer
;
1230 static const WCHAR refererW
[] = {'R','e','f','e','r','e','r'};
1232 TRACE("(%p)->(%p %d)\n", This
, aReferrer
, aReferrerPolicy
);
1235 FIXME("refferer policy %d not implemented\n", aReferrerPolicy
);
1237 if(This
->referrer
) {
1238 nsIURI_Release(This
->referrer
);
1239 This
->referrer
= NULL
;
1244 nsres
= nsIURI_QueryInterface(aReferrer
, &IID_nsWineURI
, (void**)&referrer
);
1245 if(NS_FAILED(nsres
))
1248 if(!ensure_uri(referrer
)) {
1249 nsIFileURL_Release(&referrer
->nsIFileURL_iface
);
1250 return NS_ERROR_UNEXPECTED
;
1253 if(!ensure_uri(This
->uri
) || FAILED(IUri_GetScheme(This
->uri
->uri
, &channel_scheme
)))
1254 channel_scheme
= INTERNET_SCHEME_UNKNOWN
;
1256 if(FAILED(IUri_GetScheme(referrer
->uri
, &referrer_scheme
)))
1257 referrer_scheme
= INTERNET_SCHEME_UNKNOWN
;
1259 if(referrer_scheme
== INTERNET_SCHEME_HTTPS
&& channel_scheme
!= INTERNET_SCHEME_HTTPS
) {
1260 TRACE("Ignoring https referrer on non-https channel\n");
1261 nsIFileURL_Release(&referrer
->nsIFileURL_iface
);
1265 hres
= IUri_GetDisplayUri(referrer
->uri
, &referrer_uri
);
1266 if(SUCCEEDED(hres
)) {
1267 set_http_header(&This
->request_headers
, refererW
, ARRAY_SIZE(refererW
), referrer_uri
, SysStringLen(referrer_uri
));
1268 SysFreeString(referrer_uri
);
1271 This
->referrer
= (nsIURI
*)&referrer
->nsIFileURL_iface
;
1275 static nsresult NSAPI
nsHttpChannel_GetProtocolVersion(nsIHttpChannel
*iface
, nsACString
*aProtocolVersion
)
1277 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1278 FIXME("(%p)->(%p)\n", This
, aProtocolVersion
);
1279 return NS_ERROR_NOT_IMPLEMENTED
;
1282 static nsresult NSAPI
nsHttpChannel_GetTransferSize(nsIHttpChannel
*iface
, UINT64
*aTransferSize
)
1284 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1285 FIXME("(%p)->(%p)\n", This
, aTransferSize
);
1286 return NS_ERROR_NOT_IMPLEMENTED
;
1289 static nsresult NSAPI
nsHttpChannel_GetDecodedBodySize(nsIHttpChannel
*iface
, UINT64
*aDecodedBodySize
)
1291 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1292 FIXME("(%p)->(%p)\n", This
, aDecodedBodySize
);
1293 return NS_ERROR_NOT_IMPLEMENTED
;
1296 static nsresult NSAPI
nsHttpChannel_GetEncodedBodySize(nsIHttpChannel
*iface
, UINT64
*aEncodedBodySize
)
1298 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1299 FIXME("(%p)->(%p)\n", This
, aEncodedBodySize
);
1300 return NS_ERROR_NOT_IMPLEMENTED
;
1303 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
1304 const nsACString
*aHeader
, nsACString
*_retval
)
1306 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1308 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aHeader
), _retval
);
1310 return get_channel_http_header(&This
->request_headers
, aHeader
, _retval
);
1313 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
1314 const nsACString
*aHeader
, const nsACString
*aValue
, cpp_bool aMerge
)
1316 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1318 TRACE("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(aHeader
), debugstr_nsacstr(aValue
), aMerge
);
1321 FIXME("aMerge not supported\n");
1323 return set_channel_http_header(&This
->request_headers
, aHeader
, aValue
);
1326 static nsresult NSAPI
nsChannel_SetEmptyRequestHeader(nsIHttpChannel
*iface
, const nsACString
*aHeader
)
1328 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1329 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aHeader
));
1330 return NS_ERROR_NOT_IMPLEMENTED
;
1333 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
1334 nsIHttpHeaderVisitor
*aVisitor
)
1336 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1338 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1340 return NS_ERROR_NOT_IMPLEMENTED
;
1343 static nsresult NSAPI
nsChannel_VisitNonDefaultRequestHeaders(nsIHttpChannel
*iface
, nsIHttpHeaderVisitor
*aVisitor
)
1345 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1346 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1347 return NS_ERROR_NOT_IMPLEMENTED
;
1350 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, cpp_bool
*aAllowPipelining
)
1352 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1354 FIXME("(%p)->(%p)\n", This
, aAllowPipelining
);
1356 return NS_ERROR_NOT_IMPLEMENTED
;
1359 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, cpp_bool aAllowPipelining
)
1361 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1363 FIXME("(%p)->(%x)\n", This
, aAllowPipelining
);
1365 return NS_ERROR_NOT_IMPLEMENTED
;
1368 static nsresult NSAPI
nsChannel_GetAllowTLS(nsIHttpChannel
*iface
, cpp_bool
*aAllowTLS
)
1370 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1371 FIXME("(%p)->(%p)\n", This
, aAllowTLS
);
1372 return NS_ERROR_NOT_IMPLEMENTED
;
1375 static nsresult NSAPI
nsChannel_SetAllowTLS(nsIHttpChannel
*iface
, cpp_bool aAllowTLS
)
1377 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1378 FIXME("(%p)->(%x)\n", This
, aAllowTLS
);
1379 return NS_ERROR_NOT_IMPLEMENTED
;
1382 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, UINT32
*aRedirectionLimit
)
1384 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1386 FIXME("(%p)->(%p)\n", This
, aRedirectionLimit
);
1388 return NS_ERROR_NOT_IMPLEMENTED
;
1391 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, UINT32 aRedirectionLimit
)
1393 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1395 FIXME("(%p)->(%u)\n", This
, aRedirectionLimit
);
1397 return NS_ERROR_NOT_IMPLEMENTED
;
1400 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, UINT32
*aResponseStatus
)
1402 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1404 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
1406 if(This
->response_status
) {
1407 *aResponseStatus
= This
->response_status
;
1411 WARN("No response status\n");
1412 return NS_ERROR_UNEXPECTED
;
1415 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
1416 nsACString
*aResponseStatusText
)
1418 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1420 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
1422 nsACString_SetData(aResponseStatusText
, This
->response_status_text
);
1426 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
1427 cpp_bool
*aRequestSucceeded
)
1429 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1431 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
1433 if(!This
->response_status
)
1434 return NS_ERROR_NOT_AVAILABLE
;
1436 *aRequestSucceeded
= This
->response_status
/100 == 2;
1441 static nsresult NSAPI
nsChannel_GetIsMainDocumentChannel(nsIHttpChannel
*iface
, cpp_bool
*aIsMainDocumentChannel
)
1443 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1444 FIXME("(%p)->(%p)\n", This
, aIsMainDocumentChannel
);
1445 return NS_ERROR_NOT_IMPLEMENTED
;
1448 static nsresult NSAPI
nsChannel_SetIsMainDocumentChannel(nsIHttpChannel
*iface
, cpp_bool aIsMainDocumentChannel
)
1450 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1451 FIXME("(%p)->(%x)\n", This
, aIsMainDocumentChannel
);
1452 return NS_ERROR_NOT_IMPLEMENTED
;
1455 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
1456 const nsACString
*header
, nsACString
*_retval
)
1458 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1460 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(header
), _retval
);
1462 return get_channel_http_header(&This
->response_headers
, header
, _retval
);
1465 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
1466 const nsACString
*header
, const nsACString
*value
, cpp_bool merge
)
1468 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1470 FIXME("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(header
), debugstr_nsacstr(value
), merge
);
1472 return NS_ERROR_NOT_IMPLEMENTED
;
1475 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
1476 nsIHttpHeaderVisitor
*aVisitor
)
1478 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1480 TRACE("(%p)->(%p)\n", This
, aVisitor
);
1482 return visit_http_headers(&This
->response_headers
, aVisitor
);
1485 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1487 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1488 http_header_t
*header
;
1490 static const WCHAR cache_controlW
[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l'};
1491 static const WCHAR no_storeW
[] = {'n','o','-','s','t','o','r','e',0};
1493 TRACE("(%p)->(%p)\n", This
, _retval
);
1495 header
= find_http_header(&This
->response_headers
, cache_controlW
, ARRAY_SIZE(cache_controlW
));
1496 *_retval
= header
&& !wcsicmp(header
->data
, no_storeW
);
1500 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1502 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1504 FIXME("(%p)->(%p)\n", This
, _retval
);
1506 return NS_ERROR_NOT_IMPLEMENTED
;
1509 static nsresult NSAPI
nsChannel_IsPrivateResponse(nsIHttpChannel
*iface
, cpp_bool
*_retval
)
1511 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1513 FIXME("(%p)->(%p)\n", This
, _retval
);
1515 return NS_ERROR_NOT_IMPLEMENTED
;
1518 static nsresult NSAPI
nsChannel_RedirectTo(nsIHttpChannel
*iface
, nsIURI
*aTargetURI
)
1520 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1522 FIXME("(%p)->(%p)\n", This
, aTargetURI
);
1524 return NS_ERROR_NOT_IMPLEMENTED
;
1527 static nsresult NSAPI
nsHttpChannel_GetSchedulingContextID(nsIHttpChannel
*iface
, nsIID
*aSchedulingContextID
)
1529 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1531 FIXME("(%p)->(%p)\n", This
, aSchedulingContextID
);
1533 return NS_ERROR_NOT_IMPLEMENTED
;
1536 static nsresult NSAPI
nsHttpChannel_SetSchedulingContextID(nsIHttpChannel
*iface
, const nsIID aSchedulingContextID
)
1538 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1540 FIXME("(%p)->(%s)\n", This
, debugstr_guid(&aSchedulingContextID
));
1542 return NS_ERROR_NOT_IMPLEMENTED
;
1545 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1546 nsChannel_QueryInterface
,
1550 nsChannel_IsPending
,
1551 nsChannel_GetStatus
,
1555 nsChannel_GetLoadGroup
,
1556 nsChannel_SetLoadGroup
,
1557 nsChannel_GetLoadFlags
,
1558 nsChannel_SetLoadFlags
,
1559 nsChannel_GetOriginalURI
,
1560 nsChannel_SetOriginalURI
,
1564 nsChannel_GetNotificationCallbacks
,
1565 nsChannel_SetNotificationCallbacks
,
1566 nsChannel_GetSecurityInfo
,
1567 nsChannel_GetContentType
,
1568 nsChannel_SetContentType
,
1569 nsChannel_GetContentCharset
,
1570 nsChannel_SetContentCharset
,
1571 nsChannel_GetContentLength
,
1572 nsChannel_SetContentLength
,
1575 nsChannel_AsyncOpen
,
1576 nsChannel_AsyncOpen2
,
1577 nsChannel_GetContentDisposition
,
1578 nsChannel_SetContentDisposition
,
1579 nsChannel_GetContentDispositionFilename
,
1580 nsChannel_SetContentDispositionFilename
,
1581 nsChannel_GetContentDispositionHeader
,
1582 nsChannel_GetLoadInfo
,
1583 nsChannel_SetLoadInfo
,
1584 nsChannel_GetRequestMethod
,
1585 nsChannel_SetRequestMethod
,
1586 nsChannel_GetReferrer
,
1587 nsChannel_SetReferrer
,
1588 nsChannel_GetReferrerPolicy
,
1589 nsChannel_SetReferrerWithPolicy
,
1590 nsHttpChannel_GetProtocolVersion
,
1591 nsHttpChannel_GetTransferSize
,
1592 nsHttpChannel_GetDecodedBodySize
,
1593 nsHttpChannel_GetEncodedBodySize
,
1594 nsChannel_GetRequestHeader
,
1595 nsChannel_SetRequestHeader
,
1596 nsChannel_SetEmptyRequestHeader
,
1597 nsChannel_VisitRequestHeaders
,
1598 nsChannel_VisitNonDefaultRequestHeaders
,
1599 nsChannel_GetAllowPipelining
,
1600 nsChannel_SetAllowPipelining
,
1601 nsChannel_GetAllowTLS
,
1602 nsChannel_SetAllowTLS
,
1603 nsChannel_GetRedirectionLimit
,
1604 nsChannel_SetRedirectionLimit
,
1605 nsChannel_GetResponseStatus
,
1606 nsChannel_GetResponseStatusText
,
1607 nsChannel_GetRequestSucceeded
,
1608 nsChannel_GetIsMainDocumentChannel
,
1609 nsChannel_SetIsMainDocumentChannel
,
1610 nsChannel_GetResponseHeader
,
1611 nsChannel_SetResponseHeader
,
1612 nsChannel_VisitResponseHeaders
,
1613 nsChannel_IsNoStoreResponse
,
1614 nsChannel_IsNoCacheResponse
,
1615 nsChannel_IsPrivateResponse
,
1616 nsChannel_RedirectTo
,
1617 nsHttpChannel_GetSchedulingContextID
,
1618 nsHttpChannel_SetSchedulingContextID
1621 static inline nsChannel
*impl_from_nsIUploadChannel(nsIUploadChannel
*iface
)
1623 return CONTAINING_RECORD(iface
, nsChannel
, nsIUploadChannel_iface
);
1626 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1629 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1630 return nsIHttpChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1633 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1635 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1636 return nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
1639 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1641 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1642 return nsIHttpChannel_Release(&This
->nsIHttpChannel_iface
);
1645 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1646 nsIInputStream
*aStream
, const nsACString
*aContentType
, INT64 aContentLength
)
1648 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1649 const char *content_type
;
1651 static const WCHAR content_typeW
[] =
1652 {'C','o','n','t','e','n','t','-','T','y','p','e'};
1654 TRACE("(%p)->(%p %s %s)\n", This
, aStream
, debugstr_nsacstr(aContentType
), wine_dbgstr_longlong(aContentLength
));
1656 This
->post_data_contains_headers
= TRUE
;
1659 nsACString_GetData(aContentType
, &content_type
);
1663 ct
= heap_strdupAtoW(content_type
);
1665 return NS_ERROR_UNEXPECTED
;
1667 set_http_header(&This
->request_headers
, content_typeW
, ARRAY_SIZE(content_typeW
), ct
, lstrlenW(ct
));
1669 This
->post_data_contains_headers
= FALSE
;
1673 if(aContentLength
!= -1)
1674 FIXME("Unsupported acontentLength = %s\n", wine_dbgstr_longlong(aContentLength
));
1676 if(This
->post_data_stream
)
1677 nsIInputStream_Release(This
->post_data_stream
);
1678 This
->post_data_stream
= aStream
;
1680 nsIInputStream_AddRef(aStream
);
1682 This
->request_method
= METHOD_POST
;
1686 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1687 nsIInputStream
**aUploadStream
)
1689 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1691 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1693 if(This
->post_data_stream
)
1694 nsIInputStream_AddRef(This
->post_data_stream
);
1696 *aUploadStream
= This
->post_data_stream
;
1700 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1701 nsUploadChannel_QueryInterface
,
1702 nsUploadChannel_AddRef
,
1703 nsUploadChannel_Release
,
1704 nsUploadChannel_SetUploadStream
,
1705 nsUploadChannel_GetUploadStream
1708 static inline nsChannel
*impl_from_nsIHttpChannelInternal(nsIHttpChannelInternal
*iface
)
1710 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannelInternal_iface
);
1713 static nsresult NSAPI
nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal
*iface
, nsIIDRef riid
,
1716 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1717 return nsIHttpChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1720 static nsrefcnt NSAPI
nsHttpChannelInternal_AddRef(nsIHttpChannelInternal
*iface
)
1722 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1723 return nsIHttpChannel_AddRef(&This
->nsIHttpChannel_iface
);
1726 static nsrefcnt NSAPI
nsHttpChannelInternal_Release(nsIHttpChannelInternal
*iface
)
1728 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1729 return nsIHttpChannel_Release(&This
->nsIHttpChannel_iface
);
1732 static nsresult NSAPI
nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
**aDocumentURI
)
1734 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1736 FIXME("(%p)->()\n", This
);
1738 return NS_ERROR_NOT_IMPLEMENTED
;
1741 static nsresult NSAPI
nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
*aDocumentURI
)
1743 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1745 TRACE("(%p)->() unimplemented\n", This
);
1747 return NS_ERROR_NOT_IMPLEMENTED
;
1750 static nsresult NSAPI
nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal
*iface
, UINT32
*major
, UINT32
*minor
)
1752 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1754 FIXME("(%p)->()\n", This
);
1756 return NS_ERROR_NOT_IMPLEMENTED
;
1759 static nsresult NSAPI
nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal
*iface
, UINT32
*major
, UINT32
*minor
)
1761 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1763 FIXME("(%p)->()\n", This
);
1765 return NS_ERROR_NOT_IMPLEMENTED
;
1768 static nsresult NSAPI
nsHttpChannelInternal_TakeAllSecurityMessages(nsIHttpChannelInternal
*iface
, void *aMessages
)
1770 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1772 TRACE("(%p)->(%p) unimplemented\n", This
, aMessages
);
1774 return NS_ERROR_NOT_IMPLEMENTED
;
1777 static nsresult NSAPI
nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal
*iface
, const char *aCookieHeader
)
1779 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1781 FIXME("(%p)->()\n", This
);
1783 return NS_ERROR_NOT_IMPLEMENTED
;
1786 static nsresult NSAPI
nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal
*iface
, const char *aFallbackKey
)
1788 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1790 FIXME("(%p)->()\n", This
);
1792 return NS_ERROR_NOT_IMPLEMENTED
;
1795 static nsresult NSAPI
nsHttpChannelInternal_GetThirdPartyFlags(nsIHttpChannelInternal
*iface
, UINT32
*aThirdPartyFlags
)
1797 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1798 FIXME("(%p)->(%p)\n", This
, aThirdPartyFlags
);
1799 return NS_ERROR_NOT_IMPLEMENTED
;
1802 static nsresult NSAPI
nsHttpChannelInternal_SetThirdPartyFlags(nsIHttpChannelInternal
*iface
, UINT32 aThirdPartyFlags
)
1804 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1805 FIXME("(%p)->(%x)\n", This
, aThirdPartyFlags
);
1806 return NS_ERROR_NOT_IMPLEMENTED
;
1809 static nsresult NSAPI
nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, cpp_bool
*aForceThirdPartyCookie
)
1811 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1813 FIXME("(%p)->()\n", This
);
1815 return NS_ERROR_NOT_IMPLEMENTED
;
1818 static nsresult NSAPI
nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, cpp_bool aForceThirdPartyCookie
)
1820 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1822 FIXME("(%p)->()\n", This
);
1824 return NS_ERROR_NOT_IMPLEMENTED
;
1827 static nsresult NSAPI
nsHttpChannelInternal_GetCanceled(nsIHttpChannelInternal
*iface
, cpp_bool
*aCanceled
)
1829 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1831 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1833 return NS_ERROR_NOT_IMPLEMENTED
;
1836 static nsresult NSAPI
nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal
*iface
, cpp_bool
*aCanceled
)
1838 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1840 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1842 return NS_ERROR_NOT_IMPLEMENTED
;
1845 static nsresult NSAPI
nsHttpChannelInternal_SetChannelIsForDownload(nsIHttpChannelInternal
*iface
, cpp_bool aCanceled
)
1847 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1849 FIXME("(%p)->(%x)\n", This
, aCanceled
);
1851 return NS_ERROR_NOT_IMPLEMENTED
;
1854 static nsresult NSAPI
nsHttpChannelInternal_GetLocalAddress(nsIHttpChannelInternal
*iface
, nsACString
*aLocalAddress
)
1856 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1858 FIXME("(%p)->(%p)\n", This
, aLocalAddress
);
1860 return NS_ERROR_NOT_IMPLEMENTED
;
1863 static nsresult NSAPI
nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal
*iface
, LONG
*aLocalPort
)
1865 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1867 FIXME("(%p)->(%p)\n", This
, aLocalPort
);
1869 return NS_ERROR_NOT_IMPLEMENTED
;
1872 static nsresult NSAPI
nsHttpChannelInternal_GetRemoteAddress(nsIHttpChannelInternal
*iface
, nsACString
*aRemoteAddress
)
1874 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1876 FIXME("(%p)->(%p)\n", This
, aRemoteAddress
);
1878 return NS_ERROR_NOT_IMPLEMENTED
;
1881 static nsresult NSAPI
nsHttpChannelInternal_GetRemotePort(nsIHttpChannelInternal
*iface
, LONG
*aRemotePort
)
1883 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1885 FIXME("(%p)->(%p)\n", This
, aRemotePort
);
1887 return NS_ERROR_NOT_IMPLEMENTED
;
1890 static nsresult NSAPI
nsHttpChannelInternal_SetCacheKeysRedirectChain(nsIHttpChannelInternal
*iface
, void *cacheKeys
)
1892 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1894 FIXME("(%p)->(%p)\n", This
, cacheKeys
);
1896 return NS_ERROR_NOT_IMPLEMENTED
;
1899 static nsresult NSAPI
nsHttpChannelInternal_HTTPUpgrade(nsIHttpChannelInternal
*iface
,
1900 const nsACString
*aProtocolName
, nsIHttpUpgradeListener
*aListener
)
1902 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1903 FIXME("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aProtocolName
), aListener
);
1904 return NS_ERROR_NOT_IMPLEMENTED
;
1907 static nsresult NSAPI
nsHttpChannelInternal_GetAllowSpdy(nsIHttpChannelInternal
*iface
, cpp_bool
*aAllowSpdy
)
1909 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1910 FIXME("(%p)->(%p)\n", This
, aAllowSpdy
);
1911 return NS_ERROR_NOT_IMPLEMENTED
;
1914 static nsresult NSAPI
nsHttpChannelInternal_SetAllowSpdy(nsIHttpChannelInternal
*iface
, cpp_bool aAllowSpdy
)
1916 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1917 FIXME("(%p)->(%x)\n", This
, aAllowSpdy
);
1918 return NS_ERROR_NOT_IMPLEMENTED
;
1921 static nsresult NSAPI
nsHttpChannelInternal_GetResponseTimeoutEnabled(nsIHttpChannelInternal
*iface
,
1922 cpp_bool
*aResponseTimeoutEnabled
)
1924 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1925 FIXME("(%p)->(%p)\n", This
, aResponseTimeoutEnabled
);
1926 return NS_ERROR_NOT_IMPLEMENTED
;
1929 static nsresult NSAPI
nsHttpChannelInternal_SetResponseTimeoutEnabled(nsIHttpChannelInternal
*iface
,
1930 cpp_bool aResponseTimeoutEnabled
)
1932 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1933 FIXME("(%p)->(%x)\n", This
, aResponseTimeoutEnabled
);
1934 return NS_ERROR_NOT_IMPLEMENTED
;
1937 static nsresult NSAPI
nsHttpChannelInternal_GetInitialRwin(nsIHttpChannelInternal
*iface
,
1938 UINT32
*aInitialRwin
)
1940 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1941 FIXME("(%p)->(%p)\n", This
, aInitialRwin
);
1942 return NS_ERROR_NOT_IMPLEMENTED
;
1945 static nsresult NSAPI
nsHttpChannelInternal_SetInitialRwin(nsIHttpChannelInternal
*iface
,
1946 UINT32 aInitialRwin
)
1948 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1949 FIXME("(%p)->(%x)\n", This
, aInitialRwin
);
1950 return NS_ERROR_NOT_IMPLEMENTED
;
1953 static nsresult NSAPI
nsHttpChannelInternal_GetApiRedirectToURI(nsIHttpChannelInternal
*iface
, nsIURI
**aApiRedirectToURI
)
1955 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1956 FIXME("(%p)->(%p)\n", This
, aApiRedirectToURI
);
1957 return NS_ERROR_NOT_IMPLEMENTED
;
1960 static nsresult NSAPI
nsHttpChannelInternal_GetAllowAltSvc(nsIHttpChannelInternal
*iface
, cpp_bool
*aAllowAltSvc
)
1962 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1963 FIXME("(%p)->(%p)\n", This
, aAllowAltSvc
);
1964 return NS_ERROR_NOT_IMPLEMENTED
;
1967 static nsresult NSAPI
nsHttpChannelInternal_SetAllowAltSvc(nsIHttpChannelInternal
*iface
, cpp_bool aAllowAltSvc
)
1969 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1970 FIXME("(%p)->(%x)\n", This
, aAllowAltSvc
);
1971 return NS_ERROR_NOT_IMPLEMENTED
;
1974 static nsresult NSAPI
nsHttpChannelInternal_GetLastModifiedTime(nsIHttpChannelInternal
*iface
, PRTime
*aLastModifiedTime
)
1976 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1977 FIXME("(%p)->(%p)\n", This
, aLastModifiedTime
);
1978 return NS_ERROR_NOT_IMPLEMENTED
;
1981 static nsresult NSAPI
nsHttpChannelInternal_ForceIntercepted(nsIHttpChannelInternal
*iface
, UINT64 aInterceptionID
)
1983 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1984 FIXME("(%p)->(%s)\n", This
, wine_dbgstr_longlong(aInterceptionID
));
1985 return NS_ERROR_NOT_IMPLEMENTED
;
1988 static nsresult NSAPI
nsHttpChannelInternal_GetResponseSynthesized(nsIHttpChannelInternal
*iface
, cpp_bool
*ResponseSynthesized
)
1990 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1991 FIXME("(%p, %p)\n", This
, ResponseSynthesized
);
1992 return NS_ERROR_NOT_IMPLEMENTED
;
1995 static nsresult NSAPI
nsHttpChannelInternal_GetCorsIncludeCredentials(nsIHttpChannelInternal
*iface
,
1996 cpp_bool
*aCorsIncludeCredentials
)
1998 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1999 FIXME("(%p)->(%p)\n", This
, aCorsIncludeCredentials
);
2000 return NS_ERROR_NOT_IMPLEMENTED
;
2003 static nsresult NSAPI
nsHttpChannelInternal_SetCorsIncludeCredentials(nsIHttpChannelInternal
*iface
,
2004 cpp_bool aCorsIncludeCredentials
)
2006 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2007 TRACE("(%p)->(%x)\n", This
, aCorsIncludeCredentials
);
2011 static nsresult NSAPI
nsHttpChannelInternal_GetCorsMode(nsIHttpChannelInternal
*iface
, UINT32
*aCorsMode
)
2013 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2014 FIXME("(%p)->(%p)\n", This
, aCorsMode
);
2015 return NS_ERROR_NOT_IMPLEMENTED
;
2018 static nsresult NSAPI
nsHttpChannelInternal_SetCorsMode(nsIHttpChannelInternal
*iface
, UINT32 aCorsMode
)
2020 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2021 TRACE("(%p)->(%d)\n", This
, aCorsMode
);
2025 static nsresult NSAPI
nsHttpChannelInternal_GetRedirectMode(nsIHttpChannelInternal
*iface
, UINT32
*aRedirectMode
)
2027 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2028 FIXME("(%p)->(%p)\n", This
, aRedirectMode
);
2029 return NS_ERROR_NOT_IMPLEMENTED
;
2032 static nsresult NSAPI
nsHttpChannelInternal_SetRedirectMode(nsIHttpChannelInternal
*iface
, UINT32 aRedirectMode
)
2034 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2035 TRACE("(%p)->(%d) unimplemented\n", This
, aRedirectMode
);
2036 return NS_ERROR_NOT_IMPLEMENTED
;
2039 static nsresult NSAPI
nsHttpChannelInternal_GetTopWindowURI(nsIHttpChannelInternal
*iface
, nsIURI
**aTopWindowURI
)
2041 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2042 FIXME("(%p)->(%p)\n", This
, aTopWindowURI
);
2043 return NS_ERROR_NOT_IMPLEMENTED
;
2046 static nsresult NSAPI
nsHttpChannelInternal_GetNetworkInterfaceId(nsIHttpChannelInternal
*iface
,
2047 nsACString
*aNetworkInterfaceId
)
2049 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2050 FIXME("(%p)->(%p)\n", This
, aNetworkInterfaceId
);
2051 return NS_ERROR_NOT_IMPLEMENTED
;
2054 static nsresult NSAPI
nsHttpChannelInternal_SetNetworkInterfaceId(nsIHttpChannelInternal
*iface
,
2055 const nsACString
*aNetworkInterfaceId
)
2057 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2058 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aNetworkInterfaceId
));
2059 return NS_ERROR_NOT_IMPLEMENTED
;
2062 static nsresult NSAPI
nsHttpChannelInternal_GetProxyURI(nsIHttpChannelInternal
*iface
, nsIURI
**aProxyURI
)
2064 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2065 FIXME("(%p)->(%p)\n", This
, aProxyURI
);
2066 return NS_ERROR_NOT_IMPLEMENTED
;
2069 static nsresult NSAPI
nsHttpChannelInternal_SetCorsPreflightParameters(nsIHttpChannelInternal
*iface
,
2070 const void /*nsTArray<nsCString>*/ *unsafeHeaders
)
2072 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2073 FIXME("(%p)->(%p)\n", This
, unsafeHeaders
);
2074 return NS_ERROR_NOT_IMPLEMENTED
;
2077 static nsresult NSAPI
nsHttpChannelInternal_GetBlockAuthPrompt(nsIHttpChannelInternal
*iface
, cpp_bool
*aBlockAuthPrompt
)
2079 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2080 FIXME("(%p)->(%p)\n", This
, aBlockAuthPrompt
);
2081 return NS_ERROR_NOT_IMPLEMENTED
;
2084 static nsresult NSAPI
nsHttpChannelInternal_SetBlockAuthPrompt(nsIHttpChannelInternal
*iface
, cpp_bool aBlockAuthPrompt
)
2086 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
2087 FIXME("(%p)->(%x)\n", This
, aBlockAuthPrompt
);
2088 return NS_ERROR_NOT_IMPLEMENTED
;
2091 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl
= {
2092 nsHttpChannelInternal_QueryInterface
,
2093 nsHttpChannelInternal_AddRef
,
2094 nsHttpChannelInternal_Release
,
2095 nsHttpChannelInternal_GetDocumentURI
,
2096 nsHttpChannelInternal_SetDocumentURI
,
2097 nsHttpChannelInternal_GetRequestVersion
,
2098 nsHttpChannelInternal_GetResponseVersion
,
2099 nsHttpChannelInternal_TakeAllSecurityMessages
,
2100 nsHttpChannelInternal_SetCookie
,
2101 nsHttpChannelInternal_SetupFallbackChannel
,
2102 nsHttpChannelInternal_GetThirdPartyFlags
,
2103 nsHttpChannelInternal_SetThirdPartyFlags
,
2104 nsHttpChannelInternal_GetForceAllowThirdPartyCookie
,
2105 nsHttpChannelInternal_SetForceAllowThirdPartyCookie
,
2106 nsHttpChannelInternal_GetCanceled
,
2107 nsHttpChannelInternal_GetChannelIsForDownload
,
2108 nsHttpChannelInternal_SetChannelIsForDownload
,
2109 nsHttpChannelInternal_GetLocalAddress
,
2110 nsHttpChannelInternal_GetLocalPort
,
2111 nsHttpChannelInternal_GetRemoteAddress
,
2112 nsHttpChannelInternal_GetRemotePort
,
2113 nsHttpChannelInternal_SetCacheKeysRedirectChain
,
2114 nsHttpChannelInternal_HTTPUpgrade
,
2115 nsHttpChannelInternal_GetAllowSpdy
,
2116 nsHttpChannelInternal_SetAllowSpdy
,
2117 nsHttpChannelInternal_GetResponseTimeoutEnabled
,
2118 nsHttpChannelInternal_SetResponseTimeoutEnabled
,
2119 nsHttpChannelInternal_GetInitialRwin
,
2120 nsHttpChannelInternal_SetInitialRwin
,
2121 nsHttpChannelInternal_GetApiRedirectToURI
,
2122 nsHttpChannelInternal_GetAllowAltSvc
,
2123 nsHttpChannelInternal_SetAllowAltSvc
,
2124 nsHttpChannelInternal_GetLastModifiedTime
,
2125 nsHttpChannelInternal_ForceIntercepted
,
2126 nsHttpChannelInternal_GetResponseSynthesized
,
2127 nsHttpChannelInternal_GetCorsIncludeCredentials
,
2128 nsHttpChannelInternal_SetCorsIncludeCredentials
,
2129 nsHttpChannelInternal_GetCorsMode
,
2130 nsHttpChannelInternal_SetCorsMode
,
2131 nsHttpChannelInternal_GetRedirectMode
,
2132 nsHttpChannelInternal_SetRedirectMode
,
2133 nsHttpChannelInternal_GetTopWindowURI
,
2134 nsHttpChannelInternal_GetNetworkInterfaceId
,
2135 nsHttpChannelInternal_SetNetworkInterfaceId
,
2136 nsHttpChannelInternal_GetProxyURI
,
2137 nsHttpChannelInternal_SetCorsPreflightParameters
,
2138 nsHttpChannelInternal_GetBlockAuthPrompt
,
2139 nsHttpChannelInternal_SetBlockAuthPrompt
2143 static void invalidate_uri(nsWineURI
*This
)
2146 IUri_Release(This
->uri
);
2151 static BOOL
ensure_uri_builder(nsWineURI
*This
)
2153 if(!This
->is_mutable
) {
2154 WARN("Not mutable URI\n");
2158 if(!This
->uri_builder
) {
2161 if(!ensure_uri(This
))
2164 hres
= CreateIUriBuilder(This
->uri
, 0, 0, &This
->uri_builder
);
2166 WARN("CreateIUriBuilder failed: %08x\n", hres
);
2171 invalidate_uri(This
);
2175 static nsresult
get_uri_string(nsWineURI
*This
, Uri_PROPERTY prop
, nsACString
*ret
)
2181 if(!ensure_uri(This
))
2182 return NS_ERROR_UNEXPECTED
;
2184 hres
= IUri_GetPropertyBSTR(This
->uri
, prop
, &val
, 0);
2186 WARN("GetPropertyBSTR failed: %08x\n", hres
);
2187 return NS_ERROR_UNEXPECTED
;
2190 vala
= heap_strdupWtoU(val
);
2193 return NS_ERROR_OUT_OF_MEMORY
;
2195 TRACE("ret %s\n", debugstr_a(vala
));
2196 nsACString_SetData(ret
, vala
);
2201 static inline nsWineURI
*impl_from_nsIFileURL(nsIFileURL
*iface
)
2203 return CONTAINING_RECORD(iface
, nsWineURI
, nsIFileURL_iface
);
2206 static nsresult NSAPI
nsURI_QueryInterface(nsIFileURL
*iface
, nsIIDRef riid
, void **result
)
2208 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2212 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2213 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
2214 *result
= &This
->nsIFileURL_iface
;
2215 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
2216 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
2217 *result
= &This
->nsIFileURL_iface
;
2218 }else if(IsEqualGUID(&IID_nsIURL
, riid
)) {
2219 TRACE("(%p)->(IID_nsIURL %p)\n", This
, result
);
2220 *result
= &This
->nsIFileURL_iface
;
2221 }else if(IsEqualGUID(&IID_nsIFileURL
, riid
)) {
2222 TRACE("(%p)->(IID_nsIFileURL %p)\n", This
, result
);
2223 *result
= This
->scheme
== URL_SCHEME_FILE
? &This
->nsIFileURL_iface
: NULL
;
2224 }else if(IsEqualGUID(&IID_nsIMutable
, riid
)) {
2225 TRACE("(%p)->(IID_nsIMutable %p)\n", This
, result
);
2226 *result
= &This
->nsIStandardURL_iface
;
2227 }else if(IsEqualGUID(&IID_nsIStandardURL
, riid
)) {
2228 TRACE("(%p)->(IID_nsIStandardURL %p)\n", This
, result
);
2229 *result
= &This
->nsIStandardURL_iface
;
2230 }else if(IsEqualGUID(&IID_nsWineURI
, riid
)) {
2231 TRACE("(%p)->(IID_nsWineURI %p)\n", This
, result
);
2236 nsIFileURL_AddRef(&This
->nsIFileURL_iface
);
2240 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
2241 return NS_NOINTERFACE
;
2244 static nsrefcnt NSAPI
nsURI_AddRef(nsIFileURL
*iface
)
2246 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2247 LONG ref
= InterlockedIncrement(&This
->ref
);
2249 TRACE("(%p) ref=%d\n", This
, ref
);
2254 static nsrefcnt NSAPI
nsURI_Release(nsIFileURL
*iface
)
2256 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2257 LONG ref
= InterlockedDecrement(&This
->ref
);
2259 TRACE("(%p) ref=%d\n", This
, ref
);
2263 IUri_Release(This
->uri
);
2264 if(This
->uri_builder
)
2265 IUriBuilder_Release(This
->uri_builder
);
2272 static nsresult NSAPI
nsURI_GetSpec(nsIFileURL
*iface
, nsACString
*aSpec
)
2274 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2276 TRACE("(%p)->(%p)\n", This
, aSpec
);
2278 return get_uri_string(This
, Uri_PROPERTY_DISPLAY_URI
, aSpec
);
2281 static nsresult NSAPI
nsURI_SetSpec(nsIFileURL
*iface
, const nsACString
*aSpec
)
2283 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2289 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aSpec
));
2291 if(!This
->is_mutable
)
2292 return NS_ERROR_UNEXPECTED
;
2294 nsACString_GetData(aSpec
, &speca
);
2295 spec
= heap_strdupUtoW(speca
);
2297 return NS_ERROR_OUT_OF_MEMORY
;
2299 hres
= create_uri(spec
, 0, &uri
);
2302 WARN("create_uri failed: %08x\n", hres
);
2303 return NS_ERROR_FAILURE
;
2306 invalidate_uri(This
);
2307 if(This
->uri_builder
) {
2308 IUriBuilder_Release(This
->uri_builder
);
2309 This
->uri_builder
= NULL
;
2316 static nsresult NSAPI
nsURI_GetPrePath(nsIFileURL
*iface
, nsACString
*aPrePath
)
2318 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2319 IUriBuilder
*uri_builder
;
2326 TRACE("(%p)->(%p)\n", This
, aPrePath
);
2328 if(!ensure_uri(This
))
2329 return NS_ERROR_UNEXPECTED
;
2331 hres
= CreateIUriBuilder(This
->uri
, 0, 0, &uri_builder
);
2333 return NS_ERROR_FAILURE
;
2335 hres
= IUriBuilder_RemoveProperties(uri_builder
, Uri_HAS_PATH
|Uri_HAS_QUERY
|Uri_HAS_FRAGMENT
);
2337 hres
= IUriBuilder_CreateUriSimple(uri_builder
, 0, 0, &uri
);
2338 IUriBuilder_Release(uri_builder
);
2340 return NS_ERROR_FAILURE
;
2342 hres
= IUri_GetDisplayUri(uri
, &display_uri
);
2345 return NS_ERROR_FAILURE
;
2347 /* Remove trailing slash that may be appended as default path. */
2348 len
= SysStringLen(display_uri
);
2349 if(len
&& display_uri
[len
-1] == '/')
2350 display_uri
[len
-1] = 0;
2352 nsres
= return_wstr_nsacstr(aPrePath
, display_uri
, -1);
2353 SysFreeString(display_uri
);
2357 static nsresult NSAPI
nsURI_GetScheme(nsIFileURL
*iface
, nsACString
*aScheme
)
2359 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2363 TRACE("(%p)->(%p)\n", This
, aScheme
);
2365 if(!ensure_uri(This
))
2366 return NS_ERROR_UNEXPECTED
;
2368 hres
= IUri_GetScheme(This
->uri
, &scheme
);
2370 WARN("GetScheme failed: %08x\n", hres
);
2371 return NS_ERROR_UNEXPECTED
;
2374 if(scheme
== URL_SCHEME_ABOUT
) {
2375 nsACString_SetData(aScheme
, "wine");
2379 return get_uri_string(This
, Uri_PROPERTY_SCHEME_NAME
, aScheme
);
2382 static nsresult NSAPI
nsURI_SetScheme(nsIFileURL
*iface
, const nsACString
*aScheme
)
2384 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2385 const char *schemea
;
2389 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aScheme
));
2391 if(!ensure_uri_builder(This
))
2392 return NS_ERROR_UNEXPECTED
;
2394 nsACString_GetData(aScheme
, &schemea
);
2395 scheme
= heap_strdupUtoW(schemea
);
2397 return NS_ERROR_OUT_OF_MEMORY
;
2399 hres
= IUriBuilder_SetSchemeName(This
->uri_builder
, scheme
);
2402 return NS_ERROR_UNEXPECTED
;
2407 static nsresult NSAPI
nsURI_GetUserPass(nsIFileURL
*iface
, nsACString
*aUserPass
)
2409 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2413 TRACE("(%p)->(%p)\n", This
, aUserPass
);
2415 if(!ensure_uri(This
))
2416 return NS_ERROR_UNEXPECTED
;
2418 hres
= IUri_GetUserName(This
->uri
, &user
);
2420 return NS_ERROR_FAILURE
;
2422 hres
= IUri_GetPassword(This
->uri
, &pass
);
2424 SysFreeString(user
);
2425 return NS_ERROR_FAILURE
;
2428 if(*user
|| *pass
) {
2429 FIXME("Construct user:pass string\n");
2431 nsACString_SetData(aUserPass
, "");
2434 SysFreeString(user
);
2435 SysFreeString(pass
);
2439 static nsresult NSAPI
nsURI_SetUserPass(nsIFileURL
*iface
, const nsACString
*aUserPass
)
2441 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2442 WCHAR
*user
= NULL
, *pass
= NULL
, *buf
= NULL
;
2443 const char *user_pass
;
2446 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUserPass
));
2448 if(!ensure_uri_builder(This
))
2449 return NS_ERROR_UNEXPECTED
;
2451 nsACString_GetData(aUserPass
, &user_pass
);
2455 buf
= heap_strdupUtoW(user_pass
);
2457 return NS_ERROR_OUT_OF_MEMORY
;
2459 ptr
= wcschr(buf
, ':');
2462 }else if(ptr
!= buf
) {
2472 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
2474 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
2477 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
2480 static nsresult NSAPI
nsURI_GetUsername(nsIFileURL
*iface
, nsACString
*aUsername
)
2482 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2484 TRACE("(%p)->(%p)\n", This
, aUsername
);
2486 return get_uri_string(This
, Uri_PROPERTY_USER_NAME
, aUsername
);
2489 static nsresult NSAPI
nsURI_SetUsername(nsIFileURL
*iface
, const nsACString
*aUsername
)
2491 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2496 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUsername
));
2498 if(!ensure_uri_builder(This
))
2499 return NS_ERROR_UNEXPECTED
;
2501 nsACString_GetData(aUsername
, &usera
);
2502 user
= heap_strdupUtoW(usera
);
2504 return NS_ERROR_OUT_OF_MEMORY
;
2506 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
2509 return NS_ERROR_UNEXPECTED
;
2514 static nsresult NSAPI
nsURI_GetPassword(nsIFileURL
*iface
, nsACString
*aPassword
)
2516 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2518 TRACE("(%p)->(%p)\n", This
, aPassword
);
2520 return get_uri_string(This
, Uri_PROPERTY_PASSWORD
, aPassword
);
2523 static nsresult NSAPI
nsURI_SetPassword(nsIFileURL
*iface
, const nsACString
*aPassword
)
2525 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2530 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPassword
));
2532 if(!ensure_uri_builder(This
))
2533 return NS_ERROR_UNEXPECTED
;
2535 nsACString_GetData(aPassword
, &passa
);
2536 pass
= heap_strdupUtoW(passa
);
2538 return NS_ERROR_OUT_OF_MEMORY
;
2540 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
2543 return NS_ERROR_UNEXPECTED
;
2548 static nsresult NSAPI
nsURI_GetHostPort(nsIFileURL
*iface
, nsACString
*aHostPort
)
2550 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2556 TRACE("(%p)->(%p)\n", This
, aHostPort
);
2558 if(!ensure_uri(This
))
2559 return NS_ERROR_UNEXPECTED
;
2561 hres
= IUri_GetAuthority(This
->uri
, &val
);
2563 WARN("GetAuthority failed: %08x\n", hres
);
2564 return NS_ERROR_UNEXPECTED
;
2567 ptr
= wcschr(val
, '@');
2571 vala
= heap_strdupWtoU(ptr
);
2574 return NS_ERROR_OUT_OF_MEMORY
;
2576 TRACE("ret %s\n", debugstr_a(vala
));
2577 nsACString_SetData(aHostPort
, vala
);
2582 static nsresult NSAPI
nsURI_SetHostPort(nsIFileURL
*iface
, const nsACString
*aHostPort
)
2584 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2586 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aHostPort
));
2588 /* Not implemented by Gecko */
2589 return NS_ERROR_NOT_IMPLEMENTED
;
2592 static nsresult NSAPI
nsURI_GetHost(nsIFileURL
*iface
, nsACString
*aHost
)
2594 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2596 TRACE("(%p)->(%p)\n", This
, aHost
);
2598 return get_uri_string(This
, Uri_PROPERTY_HOST
, aHost
);
2601 static nsresult NSAPI
nsURI_SetHost(nsIFileURL
*iface
, const nsACString
*aHost
)
2603 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2608 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aHost
));
2610 if(!ensure_uri_builder(This
))
2611 return NS_ERROR_UNEXPECTED
;
2613 nsACString_GetData(aHost
, &hosta
);
2614 host
= heap_strdupUtoW(hosta
);
2616 return NS_ERROR_OUT_OF_MEMORY
;
2618 hres
= IUriBuilder_SetHost(This
->uri_builder
, host
);
2621 return NS_ERROR_UNEXPECTED
;
2626 static nsresult NSAPI
nsURI_GetPort(nsIFileURL
*iface
, LONG
*aPort
)
2628 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2632 TRACE("(%p)->(%p)\n", This
, aPort
);
2634 if(!ensure_uri(This
))
2635 return NS_ERROR_UNEXPECTED
;
2637 hres
= IUri_GetPort(This
->uri
, &port
);
2639 WARN("GetPort failed: %08x\n", hres
);
2640 return NS_ERROR_UNEXPECTED
;
2643 *aPort
= port
? port
: -1;
2647 static nsresult NSAPI
nsURI_SetPort(nsIFileURL
*iface
, LONG aPort
)
2649 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2652 TRACE("(%p)->(%d)\n", This
, aPort
);
2654 if(!ensure_uri_builder(This
))
2655 return NS_ERROR_UNEXPECTED
;
2657 hres
= IUriBuilder_SetPort(This
->uri_builder
, aPort
!= -1, aPort
);
2658 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
2661 static nsresult NSAPI
nsURI_GetPath(nsIFileURL
*iface
, nsACString
*aPath
)
2663 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2665 TRACE("(%p)->(%p)\n", This
, aPath
);
2667 return get_uri_string(This
, Uri_PROPERTY_PATH
, aPath
);
2670 static nsresult NSAPI
nsURI_SetPath(nsIFileURL
*iface
, const nsACString
*aPath
)
2672 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2677 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPath
));
2679 if(!ensure_uri_builder(This
))
2680 return NS_ERROR_UNEXPECTED
;
2682 nsACString_GetData(aPath
, &patha
);
2683 path
= heap_strdupUtoW(patha
);
2685 return NS_ERROR_OUT_OF_MEMORY
;
2687 hres
= IUriBuilder_SetPath(This
->uri_builder
, path
);
2690 return NS_ERROR_UNEXPECTED
;
2695 static nsresult NSAPI
nsURI_Equals(nsIFileURL
*iface
, nsIURI
*other
, cpp_bool
*_retval
)
2697 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2698 nsWineURI
*other_obj
;
2702 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2704 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2705 if(NS_FAILED(nsres
)) {
2706 TRACE("Could not get nsWineURI interface\n");
2711 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2714 hres
= IUri_IsEqual(This
->uri
, other_obj
->uri
, &b
);
2715 if(SUCCEEDED(hres
)) {
2719 nsres
= NS_ERROR_FAILURE
;
2722 nsres
= NS_ERROR_UNEXPECTED
;
2725 nsIFileURL_Release(&other_obj
->nsIFileURL_iface
);
2729 static nsresult NSAPI
nsURI_SchemeIs(nsIFileURL
*iface
, const char *scheme
, cpp_bool
*_retval
)
2731 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2732 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
2736 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
2738 if(!ensure_uri(This
))
2739 return NS_ERROR_UNEXPECTED
;
2741 hres
= IUri_GetSchemeName(This
->uri
, &scheme_name
);
2743 return NS_ERROR_UNEXPECTED
;
2745 MultiByteToWideChar(CP_UTF8
, 0, scheme
, -1, buf
, ARRAY_SIZE(buf
));
2746 *_retval
= !wcscmp(scheme_name
, buf
);
2747 SysFreeString(scheme_name
);
2751 static nsresult NSAPI
nsURI_Clone(nsIFileURL
*iface
, nsIURI
**_retval
)
2753 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2754 nsWineURI
*wine_uri
;
2757 TRACE("(%p)->(%p)\n", This
, _retval
);
2759 if(!ensure_uri(This
))
2760 return NS_ERROR_UNEXPECTED
;
2762 nsres
= create_nsuri(This
->uri
, &wine_uri
);
2763 if(NS_FAILED(nsres
)) {
2764 WARN("create_nsuri failed: %08x\n", nsres
);
2768 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
2772 static nsresult NSAPI
nsURI_Resolve(nsIFileURL
*iface
, const nsACString
*aRelativePath
,
2773 nsACString
*_retval
)
2775 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2783 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aRelativePath
), _retval
);
2785 if(!ensure_uri(This
))
2786 return NS_ERROR_UNEXPECTED
;
2788 nsACString_GetData(aRelativePath
, &patha
);
2789 path
= heap_strdupUtoW(patha
);
2791 return NS_ERROR_OUT_OF_MEMORY
;
2793 hres
= combine_url(This
->uri
, path
, &new_uri
);
2796 return NS_ERROR_FAILURE
;
2798 hres
= IUri_GetDisplayUri(new_uri
, &ret
);
2799 IUri_Release(new_uri
);
2801 return NS_ERROR_FAILURE
;
2803 reta
= heap_strdupWtoU(ret
);
2806 return NS_ERROR_OUT_OF_MEMORY
;
2808 TRACE("returning %s\n", debugstr_a(reta
));
2809 nsACString_SetData(_retval
, reta
);
2814 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIFileURL
*iface
, nsACString
*aAsciiSpec
)
2816 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2818 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
2820 return nsIFileURL_GetSpec(&This
->nsIFileURL_iface
, aAsciiSpec
);
2823 static nsresult NSAPI
nsURI_GetAsciiHostPort(nsIFileURL
*iface
, nsACString
*aAsciiHostPort
)
2825 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2827 WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This
, aAsciiHostPort
);
2829 return nsIFileURL_GetHostPort(&This
->nsIFileURL_iface
, aAsciiHostPort
);
2832 static nsresult NSAPI
nsURI_GetAsciiHost(nsIFileURL
*iface
, nsACString
*aAsciiHost
)
2834 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2836 WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This
, aAsciiHost
);
2838 return get_uri_string(This
, Uri_PROPERTY_HOST
, aAsciiHost
);
2841 static nsresult NSAPI
nsURI_GetOriginCharset(nsIFileURL
*iface
, nsACString
*aOriginCharset
)
2843 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2845 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
2847 nsACString_SetData(aOriginCharset
, NULL
); /* assume utf-8, we store URI as utf-16 anyway */
2851 static nsresult NSAPI
nsURL_GetRef(nsIFileURL
*iface
, nsACString
*aRef
)
2853 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2858 TRACE("(%p)->(%p)\n", This
, aRef
);
2860 if(!ensure_uri(This
))
2861 return NS_ERROR_UNEXPECTED
;
2863 hres
= IUri_GetFragment(This
->uri
, &ref
);
2865 return NS_ERROR_UNEXPECTED
;
2867 refa
= heap_strdupWtoU(ref
);
2870 return NS_ERROR_OUT_OF_MEMORY
;
2872 nsACString_SetData(aRef
, refa
&& *refa
== '#' ? refa
+1 : refa
);
2877 static nsresult NSAPI
nsURL_SetRef(nsIFileURL
*iface
, const nsACString
*aRef
)
2879 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2884 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRef
));
2886 if(!ensure_uri_builder(This
))
2887 return NS_ERROR_UNEXPECTED
;
2889 nsACString_GetData(aRef
, &refa
);
2890 ref
= heap_strdupUtoW(refa
);
2892 return NS_ERROR_OUT_OF_MEMORY
;
2894 hres
= IUriBuilder_SetFragment(This
->uri_builder
, ref
);
2897 return NS_ERROR_UNEXPECTED
;
2902 static nsresult NSAPI
nsURI_EqualsExceptRef(nsIFileURL
*iface
, nsIURI
*other
, cpp_bool
*_retval
)
2904 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2905 nsWineURI
*other_obj
;
2908 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2910 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2911 if(NS_FAILED(nsres
)) {
2912 TRACE("Could not get nsWineURI interface\n");
2917 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2918 *_retval
= compare_ignoring_frag(This
->uri
, other_obj
->uri
);
2921 nsres
= NS_ERROR_UNEXPECTED
;
2924 nsIFileURL_Release(&other_obj
->nsIFileURL_iface
);
2928 static nsresult NSAPI
nsURI_CloneIgnoreRef(nsIFileURL
*iface
, nsIURI
**_retval
)
2930 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2931 nsWineURI
*wine_uri
;
2935 TRACE("(%p)->(%p)\n", This
, _retval
);
2937 if(!ensure_uri(This
))
2938 return NS_ERROR_UNEXPECTED
;
2940 uri
= get_uri_nofrag(This
->uri
);
2942 return NS_ERROR_FAILURE
;
2944 nsres
= create_nsuri(uri
, &wine_uri
);
2946 if(NS_FAILED(nsres
)) {
2947 WARN("create_nsuri failed: %08x\n", nsres
);
2951 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
2955 static nsresult NSAPI
nsURI_GetSpecIgnoringRef(nsIFileURL
*iface
, nsACString
*aSpecIgnoringRef
)
2957 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2959 FIXME("(%p)->(%p)\n", This
, aSpecIgnoringRef
);
2961 return nsIFileURL_GetSpec(&This
->nsIFileURL_iface
, aSpecIgnoringRef
);
2964 static nsresult NSAPI
nsURI_GetHasRef(nsIFileURL
*iface
, cpp_bool
*aHasRef
)
2966 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2970 TRACE("(%p)->(%p)\n", This
, aHasRef
);
2972 if(!ensure_uri(This
))
2973 return NS_ERROR_UNEXPECTED
;
2975 hres
= IUri_HasProperty(This
->uri
, Uri_PROPERTY_FRAGMENT
, &b
);
2977 return NS_ERROR_FAILURE
;
2983 static nsresult NSAPI
nsURL_GetFilePath(nsIFileURL
*iface
, nsACString
*aFilePath
)
2985 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2987 TRACE("(%p)->(%p)\n", This
, aFilePath
);
2989 return nsIFileURL_GetPath(&This
->nsIFileURL_iface
, aFilePath
);
2992 static nsresult NSAPI
nsURL_SetFilePath(nsIFileURL
*iface
, const nsACString
*aFilePath
)
2994 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
2996 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFilePath
));
2998 if(!This
->is_mutable
)
2999 return NS_ERROR_UNEXPECTED
;
3001 return nsIFileURL_SetPath(&This
->nsIFileURL_iface
, aFilePath
);
3004 static nsresult NSAPI
nsURL_GetQuery(nsIFileURL
*iface
, nsACString
*aQuery
)
3006 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3012 TRACE("(%p)->(%p)\n", This
, aQuery
);
3014 if(!ensure_uri(This
))
3015 return NS_ERROR_UNEXPECTED
;
3017 hres
= IUri_GetQuery(This
->uri
, &query
);
3019 return NS_ERROR_FAILURE
;
3022 if(ptr
&& *ptr
== '?')
3025 nsres
= return_wstr_nsacstr(aQuery
, ptr
, -1);
3026 SysFreeString(query
);
3030 static nsresult NSAPI
nsURL_SetQuery(nsIFileURL
*iface
, const nsACString
*aQuery
)
3032 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3037 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aQuery
));
3039 if(!ensure_uri_builder(This
))
3040 return NS_ERROR_UNEXPECTED
;
3042 nsACString_GetData(aQuery
, &querya
);
3043 query
= heap_strdupUtoW(querya
);
3045 return NS_ERROR_OUT_OF_MEMORY
;
3047 hres
= IUriBuilder_SetQuery(This
->uri_builder
, query
);
3050 return NS_ERROR_UNEXPECTED
;
3055 static nsresult
get_uri_path(nsWineURI
*This
, BSTR
*path
, const WCHAR
**file
, const WCHAR
**ext
)
3060 if(!ensure_uri(This
))
3061 return NS_ERROR_UNEXPECTED
;
3063 hres
= IUri_GetPath(This
->uri
, path
);
3065 return NS_ERROR_FAILURE
;
3067 for(ptr
= *path
+ SysStringLen(*path
)-1; ptr
> *path
&& *ptr
!= '/' && *ptr
!= '\\'; ptr
--);
3068 if(*ptr
== '/' || *ptr
== '\\')
3073 ptr
= wcsrchr(ptr
, '.');
3075 ptr
= *path
+ SysStringLen(*path
);
3082 static nsresult NSAPI
nsURL_GetDirectory(nsIFileURL
*iface
, nsACString
*aDirectory
)
3084 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3089 TRACE("(%p)->(%p)\n", This
, aDirectory
);
3091 nsres
= get_uri_path(This
, &path
, &file
, NULL
);
3092 if(NS_FAILED(nsres
))
3095 nsres
= return_wstr_nsacstr(aDirectory
, path
, file
-path
);
3096 SysFreeString(path
);
3100 static nsresult NSAPI
nsURL_SetDirectory(nsIFileURL
*iface
, const nsACString
*aDirectory
)
3102 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3104 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aDirectory
));
3106 /* Not implemented by Gecko */
3107 return NS_ERROR_NOT_IMPLEMENTED
;
3110 static nsresult NSAPI
nsURL_GetFileName(nsIFileURL
*iface
, nsACString
*aFileName
)
3112 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3117 TRACE("(%p)->(%p)\n", This
, aFileName
);
3119 nsres
= get_uri_path(This
, &path
, &file
, NULL
);
3120 if(NS_FAILED(nsres
))
3123 nsres
= return_wstr_nsacstr(aFileName
, file
, -1);
3124 SysFreeString(path
);
3128 static nsresult NSAPI
nsURL_SetFileName(nsIFileURL
*iface
, const nsACString
*aFileName
)
3130 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3131 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileName
));
3132 return NS_ERROR_NOT_IMPLEMENTED
;
3135 static nsresult NSAPI
nsURL_GetFileBaseName(nsIFileURL
*iface
, nsACString
*aFileBaseName
)
3137 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3138 const WCHAR
*file
, *ext
;
3142 TRACE("(%p)->(%p)\n", This
, aFileBaseName
);
3144 nsres
= get_uri_path(This
, &path
, &file
, &ext
);
3145 if(NS_FAILED(nsres
))
3148 nsres
= return_wstr_nsacstr(aFileBaseName
, file
, ext
-file
);
3149 SysFreeString(path
);
3153 static nsresult NSAPI
nsURL_SetFileBaseName(nsIFileURL
*iface
, const nsACString
*aFileBaseName
)
3155 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3156 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileBaseName
));
3157 return NS_ERROR_NOT_IMPLEMENTED
;
3160 static nsresult NSAPI
nsURL_GetFileExtension(nsIFileURL
*iface
, nsACString
*aFileExtension
)
3162 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3164 TRACE("(%p)->(%p)\n", This
, aFileExtension
);
3166 return get_uri_string(This
, Uri_PROPERTY_EXTENSION
, aFileExtension
);
3169 static nsresult NSAPI
nsURL_SetFileExtension(nsIFileURL
*iface
, const nsACString
*aFileExtension
)
3171 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3172 FIXME("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileExtension
));
3173 return NS_ERROR_NOT_IMPLEMENTED
;
3176 static nsresult NSAPI
nsURL_GetCommonBaseSpec(nsIFileURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
3178 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3179 FIXME("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
3180 return NS_ERROR_NOT_IMPLEMENTED
;
3183 static nsresult NSAPI
nsURL_GetRelativeSpec(nsIFileURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
3185 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3186 FIXME("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
3187 return NS_ERROR_NOT_IMPLEMENTED
;
3190 static nsresult NSAPI
nsFileURL_GetFile(nsIFileURL
*iface
, nsIFile
**aFile
)
3192 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3193 WCHAR path
[MAX_PATH
];
3197 TRACE("(%p)->(%p)\n", This
, aFile
);
3199 hres
= CoInternetParseIUri(This
->uri
, PARSE_PATH_FROM_URL
, 0, path
, ARRAY_SIZE(path
), &size
, 0);
3201 WARN("CoInternetParseIUri failed: %08x\n", hres
);
3202 return NS_ERROR_FAILURE
;
3205 return create_nsfile(path
, aFile
);
3208 static nsresult NSAPI
nsFileURL_SetFile(nsIFileURL
*iface
, nsIFile
*aFile
)
3210 nsWineURI
*This
= impl_from_nsIFileURL(iface
);
3211 FIXME("(%p)->(%p)\n", This
, aFile
);
3212 return NS_ERROR_NOT_IMPLEMENTED
;
3215 static const nsIFileURLVtbl nsFileURLVtbl
= {
3216 nsURI_QueryInterface
,
3243 nsURI_GetAsciiHostPort
,
3245 nsURI_GetOriginCharset
,
3248 nsURI_EqualsExceptRef
,
3249 nsURI_CloneIgnoreRef
,
3250 nsURI_GetSpecIgnoringRef
,
3260 nsURL_GetFileBaseName
,
3261 nsURL_SetFileBaseName
,
3262 nsURL_GetFileExtension
,
3263 nsURL_SetFileExtension
,
3264 nsURL_GetCommonBaseSpec
,
3265 nsURL_GetRelativeSpec
,
3270 static inline nsWineURI
*impl_from_nsIStandardURL(nsIStandardURL
*iface
)
3272 return CONTAINING_RECORD(iface
, nsWineURI
, nsIStandardURL_iface
);
3275 static nsresult NSAPI
nsStandardURL_QueryInterface(nsIStandardURL
*iface
, nsIIDRef riid
,
3278 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3279 return nsIFileURL_QueryInterface(&This
->nsIFileURL_iface
, riid
, result
);
3282 static nsrefcnt NSAPI
nsStandardURL_AddRef(nsIStandardURL
*iface
)
3284 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3285 return nsIFileURL_AddRef(&This
->nsIFileURL_iface
);
3288 static nsrefcnt NSAPI
nsStandardURL_Release(nsIStandardURL
*iface
)
3290 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3291 return nsIFileURL_Release(&This
->nsIFileURL_iface
);
3294 static nsresult NSAPI
nsStandardURL_GetMutable(nsIStandardURL
*iface
, cpp_bool
*aMutable
)
3296 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3298 TRACE("(%p)->(%p)\n", This
, aMutable
);
3300 *aMutable
= This
->is_mutable
;
3304 static nsresult NSAPI
nsStandardURL_SetMutable(nsIStandardURL
*iface
, cpp_bool aMutable
)
3306 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3308 TRACE("(%p)->(%x)\n", This
, aMutable
);
3310 This
->is_mutable
= aMutable
;
3314 static nsresult NSAPI
nsStandardURL_Init(nsIStandardURL
*iface
, UINT32 aUrlType
, LONG aDefaultPort
,
3315 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
)
3317 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3318 FIXME("(%p)->(%d %d %s %s %p)\n", This
, aUrlType
, aDefaultPort
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
), aBaseURI
);
3319 return NS_ERROR_NOT_IMPLEMENTED
;
3322 static nsresult NSAPI
nsStandardURL_SetDefaultPort(nsIStandardURL
*iface
, LONG aNewDefaultPort
)
3324 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
3325 FIXME("(%p)->(%d)\n", This
, aNewDefaultPort
);
3326 return NS_ERROR_NOT_IMPLEMENTED
;
3329 static const nsIStandardURLVtbl nsStandardURLVtbl
= {
3330 nsStandardURL_QueryInterface
,
3331 nsStandardURL_AddRef
,
3332 nsStandardURL_Release
,
3333 nsStandardURL_GetMutable
,
3334 nsStandardURL_SetMutable
,
3336 nsStandardURL_SetDefaultPort
3339 static nsresult
create_nsuri(IUri
*iuri
, nsWineURI
**_retval
)
3344 ret
= heap_alloc_zero(sizeof(nsWineURI
));
3346 return NS_ERROR_OUT_OF_MEMORY
;
3348 ret
->nsIFileURL_iface
.lpVtbl
= &nsFileURLVtbl
;
3349 ret
->nsIStandardURL_iface
.lpVtbl
= &nsStandardURLVtbl
;
3351 ret
->is_mutable
= TRUE
;
3356 hres
= IUri_GetScheme(iuri
, &ret
->scheme
);
3358 ret
->scheme
= URL_SCHEME_UNKNOWN
;
3360 TRACE("retval=%p\n", ret
);
3365 HRESULT
create_doc_uri(IUri
*iuri
, nsWineURI
**ret
)
3368 nsres
= create_nsuri(iuri
, ret
);
3369 return NS_SUCCEEDED(nsres
) ? S_OK
: E_OUTOFMEMORY
;
3372 static nsresult
create_nschannel(nsWineURI
*uri
, nsChannel
**ret
)
3376 if(!ensure_uri(uri
))
3377 return NS_ERROR_UNEXPECTED
;
3379 channel
= heap_alloc_zero(sizeof(nsChannel
));
3381 return NS_ERROR_OUT_OF_MEMORY
;
3383 channel
->nsIHttpChannel_iface
.lpVtbl
= &nsChannelVtbl
;
3384 channel
->nsIUploadChannel_iface
.lpVtbl
= &nsUploadChannelVtbl
;
3385 channel
->nsIHttpChannelInternal_iface
.lpVtbl
= &nsHttpChannelInternalVtbl
;
3387 channel
->request_method
= METHOD_GET
;
3388 list_init(&channel
->response_headers
);
3389 list_init(&channel
->request_headers
);
3391 nsIFileURL_AddRef(&uri
->nsIFileURL_iface
);
3398 HRESULT
create_redirect_nschannel(const WCHAR
*url
, nsChannel
*orig_channel
, nsChannel
**ret
)
3406 hres
= create_uri(url
, 0, &iuri
);
3410 nsres
= create_nsuri(iuri
, &uri
);
3412 if(NS_FAILED(nsres
))
3415 nsres
= create_nschannel(uri
, &channel
);
3416 nsIFileURL_Release(&uri
->nsIFileURL_iface
);
3417 if(NS_FAILED(nsres
))
3420 if(orig_channel
->load_group
) {
3421 nsILoadGroup_AddRef(orig_channel
->load_group
);
3422 channel
->load_group
= orig_channel
->load_group
;
3425 if(orig_channel
->notif_callback
) {
3426 nsIInterfaceRequestor_AddRef(orig_channel
->notif_callback
);
3427 channel
->notif_callback
= orig_channel
->notif_callback
;
3430 channel
->load_flags
= orig_channel
->load_flags
| LOAD_REPLACE
;
3432 if(orig_channel
->request_method
== METHOD_POST
)
3433 FIXME("unsupported POST method\n");
3435 if(orig_channel
->original_uri
) {
3436 nsIURI_AddRef(orig_channel
->original_uri
);
3437 channel
->original_uri
= orig_channel
->original_uri
;
3440 if(orig_channel
->referrer
) {
3441 nsIURI_AddRef(orig_channel
->referrer
);
3442 channel
->referrer
= orig_channel
->referrer
;
3450 nsIProtocolHandler nsIProtocolHandler_iface
;
3454 nsIProtocolHandler
*nshandler
;
3455 } nsProtocolHandler
;
3457 static inline nsProtocolHandler
*impl_from_nsIProtocolHandler(nsIProtocolHandler
*iface
)
3459 return CONTAINING_RECORD(iface
, nsProtocolHandler
, nsIProtocolHandler_iface
);
3462 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
3465 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3469 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
3470 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
3471 *result
= &This
->nsIProtocolHandler_iface
;
3472 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
3473 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
3474 *result
= &This
->nsIProtocolHandler_iface
;
3475 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
3476 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
3477 return NS_NOINTERFACE
;
3481 nsISupports_AddRef((nsISupports
*)*result
);
3485 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
3486 return NS_NOINTERFACE
;
3489 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
3491 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3492 LONG ref
= InterlockedIncrement(&This
->ref
);
3494 TRACE("(%p) ref=%d\n", This
, ref
);
3499 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
3501 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3502 LONG ref
= InterlockedDecrement(&This
->ref
);
3504 TRACE("(%p) ref=%d\n", This
, ref
);
3508 nsIProtocolHandler_Release(This
->nshandler
);
3515 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
3517 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3519 TRACE("(%p)->(%p)\n", This
, aScheme
);
3522 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
3523 return NS_ERROR_NOT_IMPLEMENTED
;
3526 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
3529 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3531 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
3534 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
3535 return NS_ERROR_NOT_IMPLEMENTED
;
3538 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
3539 UINT32
*aProtocolFlags
)
3541 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3543 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
3546 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
3547 return NS_ERROR_NOT_IMPLEMENTED
;
3550 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
3551 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3553 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3555 TRACE("((%p)->%s %s %p %p)\n", This
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3559 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
3560 return NS_ERROR_NOT_IMPLEMENTED
;
3563 static nsresult NSAPI
nsProtocolHandler_NewChannel2(nsIProtocolHandler
*iface
,
3564 nsIURI
*aURI
, nsILoadInfo
*aLoadInfo
, nsIChannel
**_retval
)
3566 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3568 TRACE("(%p)->(%p %p %p)\n", This
, aURI
, aLoadInfo
, _retval
);
3571 return nsIProtocolHandler_NewChannel2(This
->nshandler
, aURI
, aLoadInfo
, _retval
);
3572 return NS_ERROR_NOT_IMPLEMENTED
;
3575 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
3576 nsIURI
*aURI
, nsIChannel
**_retval
)
3578 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3580 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
3583 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
3584 return NS_ERROR_NOT_IMPLEMENTED
;
3587 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
3588 LONG port
, const char *scheme
, cpp_bool
*_retval
)
3590 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3592 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
3595 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
3596 return NS_ERROR_NOT_IMPLEMENTED
;
3599 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
3600 nsProtocolHandler_QueryInterface
,
3601 nsProtocolHandler_AddRef
,
3602 nsProtocolHandler_Release
,
3603 nsProtocolHandler_GetScheme
,
3604 nsProtocolHandler_GetDefaultPort
,
3605 nsProtocolHandler_GetProtocolFlags
,
3606 nsProtocolHandler_NewURI
,
3607 nsProtocolHandler_NewChannel2
,
3608 nsProtocolHandler_NewChannel
,
3609 nsProtocolHandler_AllowPort
3612 static nsresult NSAPI
nsIOServiceHook_QueryInterface(nsIIOServiceHook
*iface
, nsIIDRef riid
,
3615 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
3616 TRACE("(IID_nsISupports %p)\n", result
);
3618 }else if(IsEqualGUID(&IID_nsIIOServiceHook
, riid
)) {
3619 TRACE("(IID_nsIIOServiceHook %p)\n", result
);
3622 ERR("(%s %p)\n", debugstr_guid(riid
), result
);
3624 return NS_NOINTERFACE
;
3627 nsISupports_AddRef((nsISupports
*)*result
);
3631 static nsrefcnt NSAPI
nsIOServiceHook_AddRef(nsIIOServiceHook
*iface
)
3636 static nsrefcnt NSAPI
nsIOServiceHook_Release(nsIIOServiceHook
*iface
)
3641 static nsresult NSAPI
nsIOServiceHook_NewChannel(nsIIOServiceHook
*iface
, nsIURI
*aURI
,
3642 nsILoadInfo
*aLoadInfo
, nsIChannel
**_retval
)
3644 nsWineURI
*wine_uri
;
3648 TRACE("(%p %p %p)\n", aURI
, aLoadInfo
, _retval
);
3650 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsWineURI
, (void**)&wine_uri
);
3651 if(NS_FAILED(nsres
)) {
3652 TRACE("Could not get nsWineURI: %08x\n", nsres
);
3653 return NS_SUCCESS_DEFAULT_ACTION
;
3656 nsres
= create_nschannel(wine_uri
, &ret
);
3657 nsIFileURL_Release(&wine_uri
->nsIFileURL_iface
);
3658 if(NS_FAILED(nsres
))
3661 nsIURI_AddRef(aURI
);
3662 ret
->original_uri
= aURI
;
3665 nsIHttpChannel_SetLoadInfo(&ret
->nsIHttpChannel_iface
, aLoadInfo
);
3667 *_retval
= (nsIChannel
*)&ret
->nsIHttpChannel_iface
;
3671 static nsresult NSAPI
nsIOServiceHook_GetProtocolHandler(nsIIOServiceHook
*iface
, nsIProtocolHandler
*aHandler
,
3672 nsIProtocolHandler
**_retval
)
3674 nsIExternalProtocolHandler
*nsexthandler
;
3675 nsProtocolHandler
*ret
;
3678 TRACE("(%p %p)\n", aHandler
, _retval
);
3680 nsres
= nsIProtocolHandler_QueryInterface(aHandler
, &IID_nsIExternalProtocolHandler
, (void**)&nsexthandler
);
3681 if(NS_FAILED(nsres
)) {
3682 nsIProtocolHandler_AddRef(aHandler
);
3683 *_retval
= aHandler
;
3687 nsIExternalProtocolHandler_Release(nsexthandler
);
3689 ret
= heap_alloc(sizeof(nsProtocolHandler
));
3691 return NS_ERROR_OUT_OF_MEMORY
;
3693 ret
->nsIProtocolHandler_iface
.lpVtbl
= &nsProtocolHandlerVtbl
;
3695 nsIProtocolHandler_AddRef(aHandler
);
3696 ret
->nshandler
= aHandler
;
3699 *_retval
= &ret
->nsIProtocolHandler_iface
;
3700 TRACE("return %p\n", *_retval
);
3704 static BOOL
is_gecko_special_uri(const char *spec
)
3706 static const char *special_schemes
[] = {"chrome:", "data:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
3709 for(i
=0; i
< ARRAY_SIZE(special_schemes
); i
++) {
3710 if(!_strnicmp(spec
, special_schemes
[i
], strlen(special_schemes
[i
])))
3714 if(!_strnicmp(spec
, "file:", 5)) {
3715 const char *ptr
= spec
+5;
3718 return is_gecko_path(ptr
);
3724 static nsresult NSAPI
nsIOServiceHook_NewURI(nsIIOServiceHook
*iface
, const nsACString
*aSpec
,
3725 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3727 nsWineURI
*wine_uri
, *base_wine_uri
= NULL
;
3728 WCHAR new_spec
[INTERNET_MAX_URL_LENGTH
];
3729 const char *spec
= NULL
;
3735 TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3738 nsACString_GetData(aSpec
, &spec
);
3739 if(is_gecko_special_uri(spec
))
3740 return NS_SUCCESS_DEFAULT_ACTION
;
3742 if(!strncmp(spec
, "wine:", 5))
3746 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsWineURI
, (void**)&base_wine_uri
);
3747 if(NS_SUCCEEDED(nsres
)) {
3748 if(!ensure_uri(base_wine_uri
))
3749 return NS_ERROR_UNEXPECTED
;
3751 WARN("Could not get base nsWineURI: %08x\n", nsres
);
3755 if(aOriginCharset
&& *aOriginCharset
&& _strnicmp(aOriginCharset
, "utf", 3)) {
3759 len
= MultiByteToWideChar(CP_UTF8
, 0, aOriginCharset
, -1, NULL
, 0);
3760 charset
= SysAllocStringLen(NULL
, len
-1);
3762 return NS_ERROR_OUT_OF_MEMORY
;
3763 MultiByteToWideChar(CP_UTF8
, 0, aOriginCharset
, -1, charset
, len
);
3765 cp
= cp_from_charset_string(charset
);
3767 SysFreeString(charset
);
3770 MultiByteToWideChar(cp
, 0, spec
, -1, new_spec
, ARRAY_SIZE(new_spec
));
3773 hres
= combine_url(base_wine_uri
->uri
, new_spec
, &urlmon_uri
);
3775 hres
= create_uri(new_spec
, 0, &urlmon_uri
);
3777 WARN("create_uri failed: %08x\n", hres
);
3781 return NS_SUCCESS_DEFAULT_ACTION
;
3783 nsres
= create_nsuri(urlmon_uri
, &wine_uri
);
3784 IUri_Release(urlmon_uri
);
3786 nsIFileURL_Release(&base_wine_uri
->nsIFileURL_iface
);
3787 if(NS_FAILED(nsres
))
3790 *_retval
= (nsIURI
*)&wine_uri
->nsIFileURL_iface
;
3794 static const char *debugstr_protocol_flags(UINT32 flags
)
3797 #define X(f) case f: return #f
3802 X(ALLOWS_PROXY_HTTP
);
3803 X(URI_INHERITS_SECURITY_CONTEXT
);
3804 X(URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT
);
3805 X(URI_LOADABLE_BY_ANYONE
);
3806 X(URI_DANGEROUS_TO_LOAD
);
3807 X(URI_IS_UI_RESOURCE
);
3808 X(URI_IS_LOCAL_FILE
);
3809 X(URI_LOADABLE_BY_SUBSUMERS
);
3810 X(URI_DOES_NOT_RETURN_DATA
);
3811 X(URI_IS_LOCAL_RESOURCE
);
3812 X(URI_OPENING_EXECUTES_SCRIPT
);
3813 X(URI_NON_PERSISTABLE
);
3814 X(URI_FORBIDS_COOKIE_ACCESS
);
3815 X(URI_CROSS_ORIGIN_NEEDS_WEBAPPS_PERM
);
3816 X(URI_SYNC_LOAD_IS_OK
);
3817 X(URI_SAFE_TO_LOAD_IN_SECURE_CONTEXT
);
3818 X(URI_FETCHABLE_BY_ANYONE
);
3821 return wine_dbg_sprintf("%08x", flags
);
3825 static nsresult NSAPI
nsIOServiceHook_ProtocolHasFlags(nsIIOServiceHook
*iface
, nsIURI
*aURI
, UINT32 aFlags
, cpp_bool
*_retval
)
3827 TRACE("(%p %s %p)\n", aURI
, debugstr_protocol_flags(aFlags
), _retval
);
3828 return NS_SUCCESS_DEFAULT_ACTION
;
3831 static nsresult NSAPI
nsIOServiceHook_URIChainHasFlags(nsIIOServiceHook
*iface
, nsIURI
*aURI
, UINT32 aFlags
, cpp_bool
*_retval
)
3833 TRACE("(%p %s %p)\n", aURI
, debugstr_protocol_flags(aFlags
), _retval
);
3835 if(aFlags
== URI_DOES_NOT_RETURN_DATA
) {
3840 return NS_SUCCESS_DEFAULT_ACTION
;
3843 static const nsIIOServiceHookVtbl nsIOServiceHookVtbl
= {
3844 nsIOServiceHook_QueryInterface
,
3845 nsIOServiceHook_AddRef
,
3846 nsIOServiceHook_Release
,
3847 nsIOServiceHook_NewChannel
,
3848 nsIOServiceHook_GetProtocolHandler
,
3849 nsIOServiceHook_NewURI
,
3850 nsIOServiceHook_ProtocolHasFlags
,
3851 nsIOServiceHook_URIChainHasFlags
3854 static nsIIOServiceHook nsIOServiceHook
= { &nsIOServiceHookVtbl
};
3856 void init_nsio(nsIComponentManager
*component_manager
)
3858 nsIFactory
*old_factory
= NULL
;
3861 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
3862 &IID_nsIFactory
, (void**)&old_factory
);
3863 if(NS_FAILED(nsres
)) {
3864 ERR("Could not get factory: %08x\n", nsres
);
3868 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
3869 if(NS_FAILED(nsres
)) {
3870 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
3871 nsIFactory_Release(old_factory
);
3875 nsres
= nsIIOService_SetHook(nsio
, &nsIOServiceHook
);
3876 assert(nsres
== NS_OK
);
3879 void release_nsio(void)
3882 nsIIOService_Release(nsio
);