Cleanup - Removed unused methods and members. Changed char* member to nsCString

This commit is contained in:
rpotts%netscape.com 1999-10-26 04:43:19 +00:00
Родитель 4754f30990
Коммит d86d3a6c06
2 изменённых файлов: 32 добавлений и 47 удалений

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

@ -25,27 +25,16 @@
#include "nsXPIDLString.h"
#include "nsHTTPAtoms.h"
nsHTTPResponse::nsHTTPResponse(nsIInputStream* i_InputStream):
mStatusString(nsnull)
nsHTTPResponse::nsHTTPResponse()
{
NS_INIT_REFCNT();
mStatus = 0;
mServerVersion = HTTP_ONE_ZERO;
mInputStream = i_InputStream;
NS_IF_ADDREF(mInputStream);
}
nsHTTPResponse::~nsHTTPResponse()
{
NS_IF_RELEASE(mInputStream);
if (mStatusString) {
nsCRT::free(mStatusString);
mStatusString = nsnull;
}
}
NS_IMPL_ISUPPORTS(nsHTTPResponse, NS_GET_IID(nsISupports))
@ -53,6 +42,8 @@ NS_IMPL_ISUPPORTS(nsHTTPResponse, NS_GET_IID(nsISupports))
nsresult nsHTTPResponse::GetContentLength(PRInt32* o_Value)
{
nsresult rv = NS_OK;
if (o_Value) {
PRInt32 err;
nsXPIDLCString value;
@ -61,27 +52,35 @@ nsresult nsHTTPResponse::GetContentLength(PRInt32* o_Value)
mHeaders.GetHeader(nsHTTPAtoms::Content_Length, getter_Copies(value));
str = value;
*o_Value = str.ToInteger(&err);
return NS_OK;
}
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
nsresult nsHTTPResponse::GetStatus(PRUint32* o_Value)
{
if (o_Value)
nsresult rv = NS_OK;
if (o_Value) {
*o_Value = mStatus;
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
nsresult nsHTTPResponse::GetStatusString(char* *o_String)
{
if (o_String)
*o_String = mStatusString;
return NS_OK;
nsresult rv = NS_OK;
if (o_String) {
*o_String = mStatusString.ToNewCString();
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
nsresult nsHTTPResponse::GetServer(char* *o_String)
@ -115,21 +114,12 @@ nsresult nsHTTPResponse::SetStatusString(const char* i_Status)
{
nsresult rv = NS_OK;
NS_ASSERTION(!mStatusString, "Overwriting status string!");
mStatusString = nsCRT::strdup(i_Status);
if (!mStatusString) {
rv = NS_ERROR_FAILURE;
}
NS_ASSERTION(mStatusString.Length() == 0, "Overwriting status string!");
mStatusString = i_Status;
return rv;
}
nsresult nsHTTPResponse::GetInputStream(nsIInputStream* *o_Stream)
{
*o_Stream = mInputStream;
return NS_OK;
}
nsresult nsHTTPResponse::GetHeaderEnumerator(nsISimpleEnumerator** aResult)
{
return mHeaders.GetEnumerator(aResult);

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

@ -24,8 +24,8 @@
#include "nsIHTTPChannel.h"
#include "nsHTTPEnums.h"
#include "nsHTTPHeaderArray.h"
#include "nsString.h"
class nsIInputStream;
/*
The nsHTTPResponse class is the response object created by the response
@ -40,9 +40,8 @@ class nsHTTPResponse : public nsISupports
{
public:
// Constructor and destructor
nsHTTPResponse(nsIInputStream* i_InputStream);
virtual ~nsHTTPResponse();
// Constructor
nsHTTPResponse();
// Methods from nsISupports
NS_DECL_ISUPPORTS
@ -55,25 +54,21 @@ public:
nsresult GetServer(char* *o_String);
nsresult SetServerVersion(const char* i_ServerVersion);
nsresult GetInputStream(nsIInputStream* *o_Stream);
nsresult GetHeader(nsIAtom* i_Header, char* *o_Value);
nsresult SetHeader(nsIAtom* i_Header, const char* o_Value);
nsresult GetHeaderEnumerator(nsISimpleEnumerator** aResult);
protected:
nsresult SetStatus(PRInt32 i_Value) { mStatus = i_Value; return NS_OK;};
nsresult SetStatusString(const char* i_Value);
NS_IMETHOD SetStatus(PRInt32 i_Value) { mStatus = i_Value; return NS_OK;};
NS_IMETHOD SetStatusString(const char* i_Value);
protected:
virtual ~nsHTTPResponse();
HTTPVersion mServerVersion;
char* mStatusString;
nsCString mStatusString;
PRUint32 mStatus;
nsIInputStream* mInputStream;
nsHTTPHeaderArray mHeaders;
friend class nsHTTPResponseListener;
};
#endif /* _nsHTTPResponse_h_ */