From 04a3d364cee12a76a87e85da87ef569d54196df7 Mon Sep 17 00:00:00 2001 From: "rpotts%netscape.com" Date: Mon, 9 Aug 1999 07:07:08 +0000 Subject: [PATCH] Implement the nsIRequest interface for nsHTTPChannel. This allows channels that are cancelled from a LoadGroup to *actually* get removed... --- netwerk/protocol/http/src/nsHTTPChannel.cpp | 28 ++++++-- netwerk/protocol/http/src/nsHTTPRequest.cpp | 79 ++++++++++++++++++++- netwerk/protocol/http/src/nsHTTPRequest.h | 10 ++- 3 files changed, 110 insertions(+), 7 deletions(-) diff --git a/netwerk/protocol/http/src/nsHTTPChannel.cpp b/netwerk/protocol/http/src/nsHTTPChannel.cpp index d0efc59be4ac..1f1192359381 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -110,25 +110,45 @@ NS_IMPL_RELEASE(nsHTTPChannel); NS_IMETHODIMP nsHTTPChannel::IsPending(PRBool *result) { - return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pRequest) { + rv = m_pRequest->IsPending(result); + } + return rv; } NS_IMETHODIMP nsHTTPChannel::Cancel(void) { - return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pRequest) { + rv = m_pRequest->Cancel(); + } + return rv; } NS_IMETHODIMP nsHTTPChannel::Suspend(void) { - return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pRequest) { + rv = m_pRequest->Suspend(); + } + return rv; } NS_IMETHODIMP nsHTTPChannel::Resume(void) { - return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pRequest) { + rv = m_pRequest->Resume(); + } + return rv; } //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/protocol/http/src/nsHTTPRequest.cpp b/netwerk/protocol/http/src/nsHTTPRequest.cpp index 03d234b16333..7fb4aab9621b 100644 --- a/netwerk/protocol/http/src/nsHTTPRequest.cpp +++ b/netwerk/protocol/http/src/nsHTTPRequest.cpp @@ -74,7 +74,80 @@ nsHTTPRequest::~nsHTTPRequest() */ } -NS_IMPL_ISUPPORTS(nsHTTPRequest, nsCOMTypeInfo::GetIID()) +NS_IMPL_ADDREF(nsHTTPRequest); +NS_IMPL_RELEASE(nsHTTPRequest); + +NS_IMETHODIMP +nsHTTPRequest::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) + return NS_ERROR_NULL_POINTER; + + *aInstancePtr = NULL; + + if (aIID.Equals(nsCOMTypeInfo::GetIID()) || + aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = NS_STATIC_CAST(nsIStreamObserver*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = NS_STATIC_CAST(nsIRequest*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + + +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: + +NS_IMETHODIMP +nsHTTPRequest::IsPending(PRBool *result) +{ + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pTransport) { + rv = m_pTransport->IsPending(result); + } + return rv; +} + +NS_IMETHODIMP +nsHTTPRequest::Cancel(void) +{ + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pTransport) { + rv = m_pTransport->Cancel(); + } + return rv; +} + +NS_IMETHODIMP +nsHTTPRequest::Suspend(void) +{ + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pTransport) { + rv = m_pTransport->Suspend(); + } + return rv; +} + +NS_IMETHODIMP +nsHTTPRequest::Resume(void) +{ + nsresult rv = NS_ERROR_NULL_POINTER; + + if (m_pTransport) { + rv = m_pTransport->Resume(); + } + return rv; +} + // Finally our own methods... @@ -412,4 +485,6 @@ nsHTTPRequest::SetConnection(nsHTTPChannel* i_pConnection) nsresult nsHTTPRequest::GetHeaderEnumerator(nsISimpleEnumerator** aResult) { return mHeaders.GetEnumerator(aResult); -} \ No newline at end of file +} + + diff --git a/netwerk/protocol/http/src/nsHTTPRequest.h b/netwerk/protocol/http/src/nsHTTPRequest.h index 8f446a41931a..e2c0f2b2baeb 100644 --- a/netwerk/protocol/http/src/nsHTTPRequest.h +++ b/netwerk/protocol/http/src/nsHTTPRequest.h @@ -23,6 +23,7 @@ #include "nsCOMPtr.h" #include "nsIStreamObserver.h" #include "nsIURL.h" +#include "nsIRequest.h" #include "nsHTTPHeaderArray.h" #include "nsHTTPEnums.h" @@ -53,7 +54,8 @@ class nsHTTPChannel; -Gagan Saksena 03/29/99 */ -class nsHTTPRequest : public nsIStreamObserver +class nsHTTPRequest : public nsIStreamObserver, + public nsIRequest { public: @@ -71,6 +73,12 @@ public: nsresult aStatus, const PRUnichar* aMsg); + // nsIRequest methods: + NS_IMETHOD IsPending(PRBool *result); + NS_IMETHOD Cancel(); + NS_IMETHOD Suspend(); + NS_IMETHOD Resume(); + // Finally our own methods... /* Set or Get a header on the request. Note that for the first iteration