git-svn-id: svn://10.0.0.236/branches/N2@23286 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gagan%netscape.com
1999-03-09 05:27:07 +00:00
parent 10d067c837
commit 59705f110a
4 changed files with 123 additions and 19 deletions

View File

@@ -18,6 +18,8 @@
#include "nsHTTPHandler.h"
#include "nsHTTPInstance.h"
#include "nsITimer.h"
#include "nsIProxy.h"
#include "plstr.h" // For PL_strcasecmp maybe DEBUG only... TODO check
NS_METHOD CreateOrGetHTTPHandler(nsIHTTPHandler* *o_HTTPHandler)
@@ -26,12 +28,14 @@ NS_METHOD CreateOrGetHTTPHandler(nsIHTTPHandler* *o_HTTPHandler)
return NS_OK;
}
nsHTTPHandler::nsHTTPHandler()
nsHTTPHandler::nsHTTPHandler():
m_pTimer(nsnull)
{
}
nsHTTPHandler::~nsHTTPHandler()
{
NS_IF_RELEASE(m_pTimer);
}
NS_IMPL_ADDREF(nsHTTPHandler);

View File

@@ -19,10 +19,6 @@
#ifndef _nsHTTPHandler_h_
#define _nsHTTPHandler_h_
#include "nsIHTTPHandler.h"
#include "nsIProxy.h"
/*
The nsHTTPHandler class is an example implementation of how a
pluggable protocol would be written by an external party. As
@@ -42,6 +38,9 @@
#include "nsIHTTPHandler.h"
#include "nsIProtocolInstance.h"
//Forward decl.
class nsITimer; //TODO check with pnunn if a new version is available, where?
class nsHTTPHandler : public nsIHTTPHandler//, public nsIProxy
{
@@ -80,6 +79,8 @@ protected:
nsHTTPHandler(void);
~nsHTTPHandler();
//This is the timer that polls on the sockets.
nsITimer* m_pTimer;
};

View File

@@ -20,17 +20,23 @@
//
#include "nsHTTPInstance.h"
nsHTTPInstance::nsHTTPInstance(nsICoolURL* i_URL):m_pURL(i_URL)
nsHTTPInstance::nsHTTPInstance(nsICoolURL* i_URL):
m_pURL(i_URL),
m_bConnected(PR_FALSE)
{
//TODO think if we need to make a copy of the URL and keep it here
//since it might get deleted off the creators thread. And the
//stream listener could be elsewhere...
}
nsHTTPInstance::~nsHTTPInstance()
{
//TODO if we keep our copy of m_pURL, then delete it too.
}
NS_IMPL_ADDREF(nsHTTPInstance);
nsresult
NS_METHOD
nsHTTPInstance::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
@@ -60,20 +66,103 @@ nsHTTPInstance::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMPL_RELEASE(nsHTTPInstance);
nsresult
nsHTTPInstance::GetInputStream( nsIInputStream* *o_Stream)
NS_METHOD
nsHTTPInstance::GetInputStream(nsIInputStream* *o_Stream)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsHTTPInstance::SetHeader(const char* i_Header, const char* i_Value)
NS_METHOD
nsHTTPInstance::Interrupt(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsHTTPInstance::GetHeader(const char* i_Header, const char* *o_Value)
NS_METHOD
nsHTTPInstance::Load(void)
{
if (m_bConnected)
return NS_ERROR_ALREADY_CONNECTED;
m_bConnected = PR_TRUE;
return NS_ERROR_NOT_IMPLEMENTED;
}
//nsIHTTPInstance functions now...
NS_METHOD
nsHTTPInstance::SetAccept(const char* i_AcceptHeader)
{
if (m_bConnected)
return NS_ERROR_ALREADY_CONNECTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD
nsHTTPInstance::SetCookie(const char* i_Cookie)
{
if (m_bConnected)
return NS_ERROR_ALREADY_CONNECTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD
nsHTTPInstance::SetUserAgent(const char* i_UserAgent)
{
if (m_bConnected)
return NS_ERROR_ALREADY_CONNECTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD
nsHTTPInstance::SetHTTPVersion(HTTPVersion i_Version)
{
if (m_bConnected)
return NS_ERROR_ALREADY_CONNECTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
PRInt32
nsHTTPInstance::GetContentLength(void) const
{
if (!m_bConnected)
((nsHTTPInstance*)this)->Load();
return -1;
}
NS_METHOD
nsHTTPInstance::GetContentType(const char* *o_Type) const
{
if (!m_bConnected)
((nsHTTPInstance*)this)->Load();
return NS_ERROR_NOT_IMPLEMENTED;
}
PRInt32
nsHTTPInstance::GetResponseStatus(void) const
{
if (!m_bConnected)
((nsHTTPInstance*)this)->Load();
return -1;
}
NS_METHOD
nsHTTPInstance::GetResponseString(const char* *o_String) const
{
if (!m_bConnected)
((nsHTTPInstance*)this)->Load();
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD
nsHTTPInstance::GetServer(const char* *o_String) const
{
if (!m_bConnected)
((nsHTTPInstance*)this)->Load();
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -45,17 +45,27 @@ public:
// Functions from nsIProtocolInstance
NS_METHOD GetInputStream( nsIInputStream* *o_Stream);
NS_METHOD GetInputStream( nsIInputStream* *o_Stream);
NS_METHOD Interrupt(void);
NS_METHOD Load(void);
// Functions from nsIHTTPInstance
NS_METHOD SetHeader(const char* i_Header, const char* i_Value);
NS_METHOD GetHeader(const char* i_Header, const char* *o_Value);
NS_METHOD SetAccept(const char* i_AcceptHeader);
//NS_METHOD SetAcceptType();
NS_METHOD SetCookie(const char* i_Cookie);
NS_METHOD SetUserAgent(const char* i_UserAgent);
NS_METHOD SetHTTPVersion(HTTPVersion i_Version = HTTP_ONE_ONE);
NS_METHOD_(PRInt32) GetContentLength(void) const;
NS_METHOD GetContentType(const char* *o_Type) const;
//NS_METHOD_(PRTime) GetDate(void) const;
NS_METHOD_(PRInt32) GetResponseStatus(void) const;
NS_METHOD GetResponseString(const char* *o_String) const;
NS_METHOD GetServer(const char* *o_String) const;
private:
nsICoolURL* m_pURL;
nsICoolURL* m_pURL;
PRBool m_bConnected;
};
#endif /* _nsHTTPInstance_h_ */