diff --git a/mozilla/network/module/nsHTTPHandler.cpp b/mozilla/network/module/nsHTTPHandler.cpp index ec1e5dfa64b..56717110469 100644 --- a/mozilla/network/module/nsHTTPHandler.cpp +++ b/mozilla/network/module/nsHTTPHandler.cpp @@ -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); diff --git a/mozilla/network/module/nsHTTPHandler.h b/mozilla/network/module/nsHTTPHandler.h index 04fc512100e..57b592df893 100644 --- a/mozilla/network/module/nsHTTPHandler.h +++ b/mozilla/network/module/nsHTTPHandler.h @@ -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; }; diff --git a/mozilla/network/module/nsHTTPInstance.cpp b/mozilla/network/module/nsHTTPInstance.cpp index fc626330d58..434f9ca33f9 100644 --- a/mozilla/network/module/nsHTTPInstance.cpp +++ b/mozilla/network/module/nsHTTPInstance.cpp @@ -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; +} + diff --git a/mozilla/network/module/nsHTTPInstance.h b/mozilla/network/module/nsHTTPInstance.h index 77013f12239..cdd70dfcb6b 100644 --- a/mozilla/network/module/nsHTTPInstance.h +++ b/mozilla/network/module/nsHTTPInstance.h @@ -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_ */