diff --git a/mozilla/network/module/nsIConnectionInfo.h b/mozilla/network/module/nsIConnectionInfo.h new file mode 100644 index 00000000000..662aabcd5f6 --- /dev/null +++ b/mozilla/network/module/nsIConnectionInfo.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIConnectionInfo_h__ +#define nsIConnectionInfo_h__ + +#include "nsISupports.h" + +#define NS_ICONNECTIONINFO_IID \ +{ 0xa6cf9062, 0x15b3, 0x11d2, \ + { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } + +class nsIURL; +class nsIInputStream; +class nsIOutputStream; +class nsIStreamListener; + +class nsIConnectionInfo : public nsISupports { +public: + /** + * Get the URL associated with this connection. + * + * @param aURL Out parameter + * @result NS_OK if successful + */ + NS_IMETHOD GetURL(nsIURL **aURL)=0; + + /** + * Get the input stream associated with this connection + * + * @param aStream Out parameter + * @result NS_OK if successful + */ + NS_IMETHOD GetInputStream(nsIInputStream **aStream)=0; + + /** + * Get the output stream associated with this connection + * + * @param aStream Out parameter + * @result NS_OK if successful + */ + NS_IMETHOD GetOutputStream(nsIOutputStream **aStream)=0; + + /** + * Get the stream listener associated with this connection + * + * @param aConsumer Out parameter + * @result NS_OK if successful + */ + NS_IMETHOD GetConsumer(nsIStreamListener **aConsumer)=0; +}; + +#endif // nsIConnectionInfo_h__ diff --git a/mozilla/network/module/nsNetStream.cpp b/mozilla/network/module/nsNetStream.cpp index 280a9c20e82..a96ab7f124c 100644 --- a/mozilla/network/module/nsNetStream.cpp +++ b/mozilla/network/module/nsNetStream.cpp @@ -28,6 +28,7 @@ extern "C" { NS_DEFINE_IID(kIInputStreamIID, NS_IINPUTSTREAM_IID); +NS_DEFINE_IID(kIConnectionInfoIID, NS_ICONNECTIONINFO_IID); #define BUFFER_BLOCK_SIZE 8192 @@ -59,7 +60,7 @@ nsConnectionInfo::nsConnectionInfo(nsIURL *aURL, } -NS_IMPL_ISUPPORTS(nsConnectionInfo,kISupportsIID); +NS_IMPL_ISUPPORTS(nsConnectionInfo, kIConnectionInfoIID); nsConnectionInfo::~nsConnectionInfo() @@ -89,7 +90,41 @@ nsConnectionInfo::~nsConnectionInfo() pContainer = nsnull; } +NS_IMETHODIMP +nsConnectionInfo::GetURL(nsIURL **aURL) +{ + *aURL = pURL; + NS_IF_ADDREF(pURL); + return NS_OK; +} + +NS_IMETHODIMP +nsConnectionInfo::GetInputStream(nsIInputStream **aStream) +{ + *aStream = (nsIInputStream *)pNetStream; + NS_IF_ADDREF(pNetStream); + + return NS_OK; +} + +NS_IMETHODIMP +nsConnectionInfo::GetOutputStream(nsIOutputStream **aStream) +{ + *aStream = (nsIOutputStream *)pNetStream; + NS_IF_ADDREF(pNetStream); + + return NS_OK; +} + +NS_IMETHODIMP +nsConnectionInfo::GetConsumer(nsIStreamListener **aConsumer) +{ + *aConsumer = pConsumer; + NS_IF_ADDREF(pConsumer); + + return NS_OK; +} nsNetlibStream::nsNetlibStream(void) { diff --git a/mozilla/network/module/nsNetStream.h b/mozilla/network/module/nsNetStream.h index 1edbc0cf689..f4c28ebe2fe 100644 --- a/mozilla/network/module/nsNetStream.h +++ b/mozilla/network/module/nsNetStream.h @@ -24,12 +24,12 @@ #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsIStreamListener.h" - +#include "nsIConnectionInfo.h" /* Forward declaration... */ class nsNetlibStream; -class nsConnectionInfo : public nsISupports +class nsConnectionInfo : public nsIConnectionInfo { public: NS_DECL_ISUPPORTS @@ -38,6 +38,11 @@ public: nsNetlibStream *aStream, nsIStreamListener *aNotify); + NS_IMETHOD GetURL(nsIURL **aURL); + NS_IMETHOD GetInputStream(nsIInputStream **aStream); + NS_IMETHOD GetOutputStream(nsIOutputStream **aStream); + NS_IMETHOD GetConsumer(nsIStreamListener **aConsumer); + protected: virtual ~nsConnectionInfo(); diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp index 93b99307e8b..cc581985702 100644 --- a/mozilla/network/module/nsURL.cpp +++ b/mozilla/network/module/nsURL.cpp @@ -255,6 +255,14 @@ PRInt32 URLImpl::GetReloadType() const void URLImpl::ToString(nsString& aString) const { + // XXX Special-case javascript: URLs for the moment. + // This code will go away when we actually start doing + // protocol-specific parsing. + if (PL_strcmp(mProtocol, "javascript") == 0) { + aString.SetString(mSpec); + return; + } + aString.SetLength(0); aString.Append(mProtocol); aString.Append("://");