Enable parsing of URL's in finger: text. bug 26753. r=valeski, a=ftang.

This commit is contained in:
bryner%uiuc.edu 2000-04-11 22:41:02 +00:00
Родитель e5740174e4
Коммит b9a3694a81
2 изменённых файлов: 52 добавлений и 4 удалений

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

@ -30,8 +30,11 @@
#include "nsISocketTransportService.h"
#include "nsIStringStream.h"
#include "nsMimeTypes.h"
#include "nsIStreamConverterService.h"
#include "nsITXTToHTMLConv.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
#define BUFFER_SEG_SIZE (4*1024)
#define BUFFER_MAX_SIZE (64*1024)
@ -267,7 +270,7 @@ nsFingerChannel::SetLoadAttributes(PRUint32 aLoadAttributes)
return NS_OK;
}
#define FINGER_TYPE TEXT_PLAIN
#define FINGER_TYPE TEXT_HTML
NS_IMETHODIMP
nsFingerChannel::GetContentType(char* *aContentType) {
@ -466,7 +469,28 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext,
// we're no longer acting as an observer.
mActAsObserver = PR_FALSE;
return aChannel->AsyncRead(this, mResponseContext);
nsCOMPtr<nsIStreamListener> converterListener;
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService,
kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString fromStr; fromStr.AssignWithConversion("text/plain");
nsAutoString toStr; toStr.AssignWithConversion("text/html");
rv = StreamConvService->AsyncConvertData(fromStr.GetUnicode(),
toStr.GetUnicode(), this, mResponseContext,
getter_AddRefs(converterListener));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
if (converter) {
nsAutoString title; title.AssignWithConversion("Finger Results");
converter->SetTitle(title.GetUnicode());
converter->PreFormatHTML(PR_TRUE);
}
return aChannel->AsyncRead(converterListener, mResponseContext);
}
}

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

@ -30,8 +30,11 @@
#include "nsISocketTransportService.h"
#include "nsIStringStream.h"
#include "nsMimeTypes.h"
#include "nsIStreamConverterService.h"
#include "nsITXTToHTMLConv.h"
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
#define BUFFER_SEG_SIZE (4*1024)
#define BUFFER_MAX_SIZE (64*1024)
@ -267,7 +270,7 @@ nsFingerChannel::SetLoadAttributes(PRUint32 aLoadAttributes)
return NS_OK;
}
#define FINGER_TYPE TEXT_PLAIN
#define FINGER_TYPE TEXT_HTML
NS_IMETHODIMP
nsFingerChannel::GetContentType(char* *aContentType) {
@ -466,7 +469,28 @@ nsFingerChannel::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext,
// we're no longer acting as an observer.
mActAsObserver = PR_FALSE;
return aChannel->AsyncRead(this, mResponseContext);
nsCOMPtr<nsIStreamListener> converterListener;
NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService,
kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString fromStr; fromStr.AssignWithConversion("text/plain");
nsAutoString toStr; toStr.AssignWithConversion("text/html");
rv = StreamConvService->AsyncConvertData(fromStr.GetUnicode(),
toStr.GetUnicode(), this, mResponseContext,
getter_AddRefs(converterListener));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITXTToHTMLConv> converter(do_QueryInterface(converterListener));
if (converter) {
nsAutoString title; title.AssignWithConversion("Finger Results");
converter->SetTitle(title.GetUnicode());
converter->PreFormatHTML(PR_TRUE);
}
return aChannel->AsyncRead(converterListener, mResponseContext);
}
}