make the URI checker handle redirections correctly. Bug 128665,

r=bbaetz, sr=darin, a=asa
This commit is contained in:
bzbarsky%mit.edu 2002-03-05 05:57:21 +00:00
Родитель aaaca0db88
Коммит dba82db564
2 изменённых файлов: 31 добавлений и 3 удалений

Просмотреть файл

@ -46,8 +46,9 @@
#include "nsReadableUtils.h" // for ToNewUnicode()
//Interfaces for addref, release and queryinterface
NS_IMPL_ISUPPORTS3(nsURIChecker, nsIURIChecker,
nsIRequest, nsIStreamListener);
NS_IMPL_ISUPPORTS5(nsURIChecker, nsIURIChecker,
nsIRequest, nsIStreamListener,
nsIHttpEventSink, nsIInterfaceRequestor);
nsURIChecker::nsURIChecker()
{
@ -118,6 +119,9 @@ nsURIChecker::AsyncCheckURI(const char* aURI, nsIRequestObserver *aObserver,
if (httpChannel)
httpChannel->SetRequestMethod("HEAD");
// Hook us up to listen to redirects and the like
mChannel->SetNotificationCallbacks(this);
// and start the request:
return mChannel->AsyncOpen(this, nsnull);
}
@ -285,3 +289,22 @@ nsURIChecker::OnDataAvailable(nsIRequest *aRequest, nsISupports *aCtxt,
return NS_BINDING_ABORTED;
}
/////////////////////////////////////////////////////
// nsIInterfaceRequestor methods:
//
NS_IMETHODIMP
nsURIChecker::GetInterface(const nsIID & aIID, void **aResult)
{
return QueryInterface(aIID, aResult);
}
/////////////////////////////////////////////////////
// nsIHttpEventSink methods:
//
NS_IMETHODIMP
nsURIChecker::OnRedirect(nsIHttpChannel *aHttpChannel, nsIChannel *aNewChannel)
{
// We have a new channel
mChannel = aNewChannel;
return NS_OK;
}

Просмотреть файл

@ -43,13 +43,16 @@
#include "nsIRequest.h"
#include "nsIChannel.h"
#include "nsIStreamListener.h"
#include "nsIHttpEventSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsCOMPtr.h"
class nsURIChecker : public nsIURIChecker, public nsIRequest,
public nsIStreamListener
public nsIStreamListener, public nsIHttpEventSink,
public nsIInterfaceRequestor
{
public:
nsURIChecker();
@ -63,6 +66,8 @@ public:
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIHTTPEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
protected:
nsresult mStatus;