2000-02-02 22:48:55 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2000-09-07 21:26:29 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public
|
2000-02-02 22:48:55 +00:00
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
2000-09-07 21:26:29 +00:00
|
|
|
* the License at http://www.mozilla.org/MPL/
|
2000-02-02 22:48:55 +00:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2000-09-07 21:26:29 +00:00
|
|
|
* The Initial Developer of the Original Code is Brian Ryner.
|
|
|
|
* Portions created by Brian Ryner are Copyright (C) 2000 Brian Ryner.
|
|
|
|
* All Rights Reserved.
|
2000-02-02 22:48:55 +00:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-09-07 21:26:29 +00:00
|
|
|
* Brian Ryner <bryner@uiuc.edu>
|
2000-02-02 22:48:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// finger implementation
|
|
|
|
|
|
|
|
#include "nsFingerChannel.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsILoadGroup.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-02-02 22:48:55 +00:00
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsISocketTransportService.h"
|
|
|
|
#include "nsIStringStream.h"
|
2000-02-23 06:53:46 +00:00
|
|
|
#include "nsMimeTypes.h"
|
2000-04-11 22:41:02 +00:00
|
|
|
#include "nsIStreamConverterService.h"
|
|
|
|
#include "nsITXTToHTMLConv.h"
|
2001-02-21 20:38:08 +00:00
|
|
|
#include "nsIProgressEventSink.h"
|
2001-01-23 22:10:34 +00:00
|
|
|
#include "nsNetUtil.h"
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
2000-04-11 22:41:02 +00:00
|
|
|
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
#define BUFFER_SEG_SIZE (4*1024)
|
|
|
|
#define BUFFER_MAX_SIZE (64*1024)
|
|
|
|
|
|
|
|
// nsFingerChannel methods
|
2000-03-29 03:58:50 +00:00
|
|
|
nsFingerChannel::nsFingerChannel()
|
|
|
|
: mContentLength(-1),
|
|
|
|
mActAsObserver(PR_TRUE),
|
|
|
|
mPort(-1),
|
|
|
|
mStatus(NS_OK)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFingerChannel::~nsFingerChannel() {
|
|
|
|
}
|
|
|
|
|
2001-02-21 20:38:08 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel,
|
|
|
|
nsIChannel,
|
|
|
|
nsIRequest,
|
|
|
|
nsIStreamListener,
|
2001-04-10 06:01:08 +00:00
|
|
|
nsIRequestObserver)
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
nsresult
|
2001-09-13 02:21:05 +00:00
|
|
|
nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsXPIDLCString autoBuffer;
|
|
|
|
|
|
|
|
NS_ASSERTION(uri, "no uri");
|
|
|
|
|
|
|
|
mUrl = uri;
|
2001-09-13 02:21:05 +00:00
|
|
|
mProxyInfo = proxyInfo;
|
2000-02-02 22:48:55 +00:00
|
|
|
|
2000-03-23 06:40:36 +00:00
|
|
|
// For security reasons, we do not allow the user to specify a
|
|
|
|
// non-default port for finger: URL's.
|
|
|
|
|
|
|
|
mPort = FINGER_PORT;
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
rv = mUrl->GetPath(getter_Copies(autoBuffer)); // autoBuffer = user@host
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// Now parse out the user and host
|
2001-03-14 02:51:01 +00:00
|
|
|
const char* buf = autoBuffer.get();
|
|
|
|
const char* pos = PL_strchr(buf, '@');
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
// Catch the case of just the host being given
|
2001-03-14 02:51:01 +00:00
|
|
|
if (!pos) {
|
|
|
|
mHost.Assign(buf);
|
|
|
|
} else {
|
|
|
|
mUser.Assign(buf,pos-buf);
|
|
|
|
mHost.Assign(pos+1); // ignore '@'
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
2001-03-14 02:51:01 +00:00
|
|
|
if (mHost.IsEmpty()) return NS_ERROR_NOT_INITIALIZED;
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsFingerChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
|
|
|
{
|
|
|
|
nsFingerChannel* fc = new nsFingerChannel();
|
|
|
|
if (fc == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(fc);
|
|
|
|
nsresult rv = fc->QueryInterface(aIID, aResult);
|
|
|
|
NS_RELEASE(fc);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIRequest methods:
|
|
|
|
|
2000-08-21 08:23:54 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetName(PRUnichar* *result)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-02-02 22:48:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::IsPending(PRBool *result)
|
|
|
|
{
|
2000-03-29 03:58:50 +00:00
|
|
|
NS_NOTREACHED("nsFingerChannel::IsPending");
|
2000-02-02 22:48:55 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 03:58:50 +00:00
|
|
|
nsFingerChannel::GetStatus(nsresult *status)
|
|
|
|
{
|
|
|
|
*status = mStatus;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::Cancel(nsresult status)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
2000-04-12 07:58:24 +00:00
|
|
|
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
2000-03-22 21:15:57 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2000-03-29 03:58:50 +00:00
|
|
|
mStatus = status;
|
2001-02-21 20:38:08 +00:00
|
|
|
if (mTransportRequest) {
|
|
|
|
rv = mTransportRequest->Cancel(status);
|
2000-03-22 21:15:57 +00:00
|
|
|
}
|
|
|
|
return rv;
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::Suspend(void)
|
|
|
|
{
|
2000-03-29 03:58:50 +00:00
|
|
|
NS_NOTREACHED("nsFingerChannel::Suspend");
|
2000-02-02 22:48:55 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::Resume(void)
|
|
|
|
{
|
2000-03-29 03:58:50 +00:00
|
|
|
NS_NOTREACHED("nsFingerChannel::Resume");
|
2000-02-02 22:48:55 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChannel methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 03:58:50 +00:00
|
|
|
nsFingerChannel::GetOriginalURI(nsIURI* *aURI)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
2000-03-29 03:58:50 +00:00
|
|
|
*aURI = mOriginalURI ? mOriginalURI : mUrl;
|
2000-02-02 22:48:55 +00:00
|
|
|
NS_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-03-29 03:58:50 +00:00
|
|
|
nsFingerChannel::SetOriginalURI(nsIURI* aURI)
|
|
|
|
{
|
|
|
|
mOriginalURI = aURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetURI(nsIURI* *aURI)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
|
|
|
*aURI = mUrl;
|
|
|
|
NS_IF_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 03:58:50 +00:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::Open(nsIInputStream **_retval)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2001-06-06 00:10:09 +00:00
|
|
|
rv = NS_CheckPortSafety(mPort, "finger");
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsISocketTransportService> socketService =
|
|
|
|
do_GetService(kSocketTransportServiceCID, &rv);
|
2000-02-02 22:48:55 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-10-24 23:47:43 +00:00
|
|
|
rv = socketService->CreateTransport(mHost.get(), mPort, mProxyInfo, BUFFER_SEG_SIZE,
|
2001-02-21 20:38:08 +00:00
|
|
|
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
2000-02-02 22:48:55 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-03-06 05:10:33 +00:00
|
|
|
mTransport->SetNotificationCallbacks(mCallbacks,
|
2001-04-10 06:01:08 +00:00
|
|
|
(mLoadFlags & LOAD_BACKGROUND));
|
2000-02-02 22:48:55 +00:00
|
|
|
|
2001-04-10 06:01:08 +00:00
|
|
|
return mTransport->OpenInputStream(0, PRUint32(-1), 0, _retval);
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2001-06-06 00:10:09 +00:00
|
|
|
rv = NS_CheckPortSafety(mPort, "finger");
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsISocketTransportService> socketService =
|
|
|
|
do_GetService(kSocketTransportServiceCID, &rv);
|
2000-02-02 22:48:55 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-10-24 23:47:43 +00:00
|
|
|
rv = socketService->CreateTransport(mHost.get(), mPort, mProxyInfo, BUFFER_SEG_SIZE,
|
2001-02-21 20:38:08 +00:00
|
|
|
BUFFER_MAX_SIZE, getter_AddRefs(mTransport));
|
2000-02-02 22:48:55 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-03-06 05:10:33 +00:00
|
|
|
mTransport->SetNotificationCallbacks(mCallbacks,
|
2001-04-10 06:01:08 +00:00
|
|
|
(mLoadFlags & LOAD_BACKGROUND));
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
mListener = aListener;
|
2000-03-22 21:15:57 +00:00
|
|
|
mResponseContext = ctxt;
|
2000-02-02 22:48:55 +00:00
|
|
|
|
2001-02-21 20:38:08 +00:00
|
|
|
return SendRequest(mTransport);
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 06:01:08 +00:00
|
|
|
nsFingerChannel::GetLoadFlags(PRUint32 *aLoadFlags)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
2001-04-10 06:01:08 +00:00
|
|
|
*aLoadFlags = mLoadFlags;
|
2000-02-02 22:48:55 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 06:01:08 +00:00
|
|
|
nsFingerChannel::SetLoadFlags(PRUint32 aLoadFlags)
|
2000-02-02 22:48:55 +00:00
|
|
|
{
|
2001-04-10 06:01:08 +00:00
|
|
|
mLoadFlags = aLoadFlags;
|
2000-02-02 22:48:55 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:41:02 +00:00
|
|
|
#define FINGER_TYPE TEXT_HTML
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetContentType(char* *aContentType) {
|
|
|
|
if (!aContentType) return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aContentType = nsCRT::strdup(FINGER_TYPE);
|
|
|
|
if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::SetContentType(const char *aContentType)
|
|
|
|
{
|
|
|
|
//It doesn't make sense to set the content-type on this type
|
|
|
|
// of channel...
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetContentLength(PRInt32 *aContentLength)
|
|
|
|
{
|
|
|
|
*aContentLength = mContentLength;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 03:58:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::SetContentLength(PRInt32 aContentLength)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("nsFingerChannel::SetContentLength");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-02-02 22:48:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
|
|
|
{
|
|
|
|
*aLoadGroup = mLoadGroup;
|
|
|
|
NS_IF_ADDREF(*aLoadGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
|
|
|
{
|
|
|
|
mLoadGroup = aLoadGroup;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetOwner(nsISupports* *aOwner)
|
|
|
|
{
|
|
|
|
*aOwner = mOwner.get();
|
|
|
|
NS_IF_ADDREF(*aOwner);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::SetOwner(nsISupports* aOwner)
|
|
|
|
{
|
|
|
|
mOwner = aOwner;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
*aNotificationCallbacks = mCallbacks.get();
|
|
|
|
NS_IF_ADDREF(*aNotificationCallbacks);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
mCallbacks = aNotificationCallbacks;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-17 22:06:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFingerChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
|
|
|
{
|
|
|
|
*aSecurityInfo = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-02 22:48:55 +00:00
|
|
|
|
2001-04-10 06:01:08 +00:00
|
|
|
// nsIRequestObserver methods
|
2000-02-02 22:48:55 +00:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) {
|
2000-02-02 22:48:55 +00:00
|
|
|
if (!mActAsObserver) {
|
|
|
|
// acting as a listener
|
2001-01-30 02:02:20 +00:00
|
|
|
return mListener->OnStartRequest(this, mResponseContext);
|
2000-02-02 22:48:55 +00:00
|
|
|
} else {
|
|
|
|
// we don't want to pass our AsyncWrite's OnStart through
|
|
|
|
// we just ignore this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::OnStopRequest(nsIRequest *aRequest, nsISupports* aContext,
|
2001-04-10 06:01:08 +00:00
|
|
|
nsresult aStatus)
|
2000-07-25 05:45:56 +00:00
|
|
|
{
|
2000-02-02 22:48:55 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-03-22 21:15:57 +00:00
|
|
|
if (NS_FAILED(aStatus) || !mActAsObserver) {
|
2000-02-02 22:48:55 +00:00
|
|
|
if (mLoadGroup) {
|
2001-04-10 06:01:08 +00:00
|
|
|
rv = mLoadGroup->RemoveRequest(this, nsnull, aStatus);
|
2000-02-02 22:48:55 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
2001-04-10 06:01:08 +00:00
|
|
|
rv = mListener->OnStopRequest(this, mResponseContext, aStatus);
|
2000-03-22 21:15:57 +00:00
|
|
|
mTransport = 0;
|
|
|
|
return rv;
|
2000-02-02 22:48:55 +00:00
|
|
|
} else {
|
|
|
|
// at this point we know the request has been sent.
|
|
|
|
// we're no longer acting as an observer.
|
|
|
|
|
|
|
|
mActAsObserver = PR_FALSE;
|
2000-04-11 22:41:02 +00:00
|
|
|
nsCOMPtr<nsIStreamListener> converterListener;
|
|
|
|
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsIStreamConverterService> StreamConvService =
|
|
|
|
do_GetService(kStreamConverterServiceCID, &rv);
|
2000-04-11 22:41:02 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString fromStr(NS_LITERAL_STRING("text/plain"));
|
|
|
|
nsAutoString toStr(NS_LITERAL_STRING("text/html"));
|
2000-04-11 22:41:02 +00:00
|
|
|
|
2001-06-30 11:02:25 +00:00
|
|
|
rv = StreamConvService->AsyncConvertData(fromStr.get(),
|
|
|
|
toStr.get(), this, mResponseContext,
|
2000-04-11 22:41:02 +00:00
|
|
|
getter_AddRefs(converterListener));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
|
|
|
|
if (converter) {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString title(NS_LITERAL_STRING("Finger information for "));
|
2000-04-18 02:40:23 +00:00
|
|
|
nsXPIDLCString userHost;
|
|
|
|
rv = mUrl->GetPath(getter_Copies(userHost));
|
2000-04-18 23:53:10 +00:00
|
|
|
title.AppendWithConversion(userHost);
|
2001-06-30 11:02:25 +00:00
|
|
|
converter->SetTitle(title.get());
|
2000-04-11 22:41:02 +00:00
|
|
|
converter->PreFormatHTML(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2001-04-10 06:01:08 +00:00
|
|
|
return mTransport->AsyncRead(converterListener, mResponseContext, 0, PRUint32(-1), 0,
|
2001-02-21 20:38:08 +00:00
|
|
|
getter_AddRefs(mTransportRequest));
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsIStreamListener method
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::OnDataAvailable(nsIRequest *aRequest, nsISupports* aContext,
|
2000-02-02 22:48:55 +00:00
|
|
|
nsIInputStream *aInputStream, PRUint32 aSourceOffset,
|
|
|
|
PRUint32 aLength) {
|
|
|
|
mContentLength = aLength;
|
2001-01-30 02:02:20 +00:00
|
|
|
return mListener->OnDataAvailable(this, mResponseContext, aInputStream, aSourceOffset, aLength);
|
2000-02-02 22:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2001-02-21 20:38:08 +00:00
|
|
|
nsFingerChannel::SendRequest(nsITransport* aTransport) {
|
2000-02-02 22:48:55 +00:00
|
|
|
// The text to send should already be in mUser
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsISupports> result;
|
|
|
|
nsCOMPtr<nsIInputStream> charstream;
|
|
|
|
nsCString requestBuffer(mUser);
|
|
|
|
|
2000-03-22 21:15:57 +00:00
|
|
|
if (mLoadGroup) {
|
2001-02-21 20:38:08 +00:00
|
|
|
mLoadGroup->AddRequest(this, nsnull);
|
2000-03-22 21:15:57 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 22:48:55 +00:00
|
|
|
requestBuffer.Append(CRLF);
|
|
|
|
|
2001-11-28 05:22:57 +00:00
|
|
|
mRequest.Assign(requestBuffer);
|
2000-02-02 22:48:55 +00:00
|
|
|
|
|
|
|
rv = NS_NewCharInputStream(getter_AddRefs(result), mRequest);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
charstream = do_QueryInterface(result, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-02-21 20:38:08 +00:00
|
|
|
rv = NS_AsyncWriteFromStream(getter_AddRefs(mTransportRequest),
|
|
|
|
aTransport, charstream,
|
|
|
|
0, requestBuffer.Length(), 0,
|
|
|
|
this, nsnull);
|
2000-02-02 22:48:55 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|