Moved the files from nunet to netwerk. For history on these files- see mozilla/nunet.

Not in the build (of netwerk) yet.
This commit is contained in:
gagan%netscape.com 1999-04-08 06:13:27 +00:00
Родитель fece7c9e61
Коммит 9a7240e61a
19 изменённых файлов: 1423 добавлений и 0 удалений

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

@ -0,0 +1,32 @@
#! gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
# Please see comments in makefile.win - Gagan Saksena
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
DIRS = file ftp http
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,8 @@
Everything that goes under this directory and subdirectory must
be written with the thinking cap of an external developer, who
knows nothing about the nasty beasts of NET_GetURL and URL_Structs
The whole world will follow example taken from these protocols, so
write good, write clean and write simple.
-Gagan

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

@ -0,0 +1,35 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugfile
LIBRARY_NAME = plugfile
EXPORTS= $(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
NO_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#------------------------------------------------------------------------
#
# Makefile to build the pluggable file: hacks
#
#------------------------------------------------------------------------
DEPTH=..\..\..
DIRS= \
src \
#tests \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,35 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugftp
LIBRARY_NAME = plugftp
EXPORTS= $(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
NO_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#------------------------------------------------------------------------
#
# Makefile to build the pluggable FTP
#
#------------------------------------------------------------------------
DEPTH=..\..\..
DIRS= \
src \
#tests \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,38 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plughttp
LIBRARY_NAME = plughttp
CSRCS = \
$(NULL)
EXPORTS= $(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
NO_STATIC_LIB=1
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#------------------------------------------------------------------------
#
# Makefile to build the pluggable HTTP
#
#------------------------------------------------------------------------
DEPTH=..\..\..
DIRS= \
src \
#tests \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,70 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#------------------------------------------------------------------------
#
# Makefile to build the pluggable HTTP
# This depends on the pluggable architecture apis exposed
# by NuNet.
#
# -Gagan Saksena 03/25/99
#
#------------------------------------------------------------------------
DEPTH=..\..\..\..
MODULE=plughttp
MAKE_OBJ_TYPE=DLL
DLLNAME=plughttp
DLL=.\$(OBJDIR)\$(DLLNAME).dll
LLIBS= $(LLIBS) \
$(LIBNSPR) \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\raptorbase.lib \
$(NULL)
MISCDEP=$(LLIBS)
EXPORTS= \
nsHTTPCID.h \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsHTTPHandler.obj \
.\$(OBJDIR)\nsHTTPHandlerFactory.obj \
.\$(OBJDIR)\nsHTTPInstance.obj \
$(NULL)
LOCAL_INCLUDES=-I.
INCLUDES = $(LOCAL_INCLUDES)
REQUIRES= nunet
LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\nunet \
-I$(PUBLIC)\xpcom \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(DLL) $(DIST)\bin\components
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib

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

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
XPCOM Class ID for the HTTP Handler that can be created with the
factory.
-Gagan Saksena 03/24/99
*/
#ifndef nsHTTPCID_h__
#define nsHTTPCID_h__
// {1C49C1D0-E254-11d2-B016-006097BFC036}
#define NS_HTTP_HANDLER_FACTORY_CID \
{ 0x1c49c1d0, 0xe254, 0x11d2, { 0xb0, 0x16, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } }
#endif // nsHTTPCID_h__

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

@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#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)
{
if (o_HTTPHandler)
{
*o_HTTPHandler = nsHTTPHandler::GetInstance();
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
}
nsHTTPHandler::nsHTTPHandler():
m_pTimer(nsnull),
mRefCnt(0)
{
}
nsHTTPHandler::~nsHTTPHandler()
{
NS_IF_RELEASE(m_pTimer);
}
NS_IMPL_ADDREF(nsHTTPHandler);
nsresult
nsHTTPHandler::GetProtocolInstance(
nsICoolURL* i_URL,
nsIProtocolInstance* *o_Instance)
{
//Assert that iURL's scheme is HTTP
//This should only happen in debug checks... TODO
const char* scheme = 0;
if (i_URL)
{
i_URL->GetScheme(&scheme);
if (0 == PL_strcasecmp(scheme, "http"))
{
//Check to see if an instance already exists in the active list
// if...
// else
// Create one
nsHTTPInstance* pNewInstance = new nsHTTPInstance(i_URL);
if (pNewInstance)
{
*o_Instance = pNewInstance;
return NS_OK;
}
else
return NS_ERROR_OUT_OF_MEMORY;
}
//return NS_ERROR_MISMATCHED_URL;
}
return NS_ERROR_NULL_POINTER;
}
nsresult
nsHTTPHandler::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(nsIProtocolHandler::GetIID())) {
*aInstancePtr = (void*) ((nsIProtocolHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIHTTPHandler::GetIID())) {
*aInstancePtr = (void*) ((nsIHTTPHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIProxy::GetIID())) {
*aInstancePtr = (void*) ((nsIProxy*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIProtocolHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_RELEASE(nsHTTPHandler);

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

@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsHTTPHandler_h_
#define _nsHTTPHandler_h_
/*
The nsHTTPHandler class is an example implementation of how a
pluggable protocol would be written by an external party. As
an example this class also uses the Proxy interface.
Since this is a completely different process boundary, I am
keeping this as a singleton. It doesn't have to be that way.
Currently this is being built with the Netlib dll. But after
the registration stuff that DP is working on gets completed
this will move to the HTTP lib.
-Gagan Saksena 02/25/99
*/
//TODO turnon the proxy stuff as well.
#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
{
public:
//Functions from nsISupports
NS_DECL_ISUPPORTS
//Functions from nsIHTTPHandler
NS_METHOD GetProtocolInstance(nsICoolURL* i_URL,
nsIProtocolInstance* *o_Instance);
//Functions from nsIProxy
/*
Get and Set the Proxy Host
*/
NS_METHOD GetProxyHost(const char* *o_ProxyHost) const {return NS_ERROR_NOT_IMPLEMENTED;};
NS_METHOD SetProxyHost(const char* i_ProxyHost) {return NS_ERROR_NOT_IMPLEMENTED;};
/*
Get and Set the Proxy Port
-1 on Set call indicates switch to default port
*/
NS_METHOD_(PRInt32)
GetProxyPort(void) const {return NS_ERROR_NOT_IMPLEMENTED;};
NS_METHOD SetProxyPort(PRInt32 i_ProxyPort) {return NS_ERROR_NOT_IMPLEMENTED;};
// Singleton function
static nsHTTPHandler* GetInstance(void)
{
static nsHTTPHandler* pHandler = new nsHTTPHandler();
return pHandler;
};
protected:
nsHTTPHandler(void);
~nsHTTPHandler();
//This is the timer that polls on the sockets.
nsITimer* m_pTimer;
};
#endif /* _nsHTTPHandler_h_ */

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

@ -0,0 +1,197 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
The nsHTTPHandlerFactory implementation. This was directly
plagiarized from Chris Waterson the Great's nsRDFFactory.cpp
So if you find a fault here... make sure you notify him as
well.
-Gagan Saksena 03/25/99
*/
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsHTTPHandlerFactory.h"
#include "nsHTTPCID.h"
#include "nsIHTTPHandler.h"
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kHTTPHandlerFactoryCID, NS_HTTP_HANDLER_FACTORY_CID);
nsHTTPHandlerFactory::nsHTTPHandlerFactory(const nsCID &aClass,
const char* className,
const char* progID)
: mClassID(aClass),
mClassName(className),
mProgID(progID)
{
NS_INIT_REFCNT();
}
nsHTTPHandlerFactory::~nsHTTPHandlerFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
nsHTTPHandlerFactory::QueryInterface(const nsIID &aIID, void **aResult)
{
if (! aResult)
return NS_ERROR_NULL_POINTER;
*aResult = nsnull;
if (aIID.Equals(nsISupports::GetIID())) {
*aResult = NS_STATIC_CAST(nsISupports*, this);
AddRef();
return NS_OK;
} else if (aIID.Equals(nsIFactory::GetIID())) {
*aResult = NS_STATIC_CAST(nsIFactory*, this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsHTTPHandlerFactory);
NS_IMPL_RELEASE(nsHTTPHandlerFactory);
NS_IMETHODIMP
nsHTTPHandlerFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
*aResult = nsnull;
nsresult rv;
nsISupports *inst = nsnull;
if (mClassID.Equals(nsIProtocolHandler::GetIID())) {
if (NS_FAILED(rv = CreateOrGetHTTPHandler((nsIHTTPHandler**) &inst)))
return rv;
}
else {
return NS_ERROR_NO_INTERFACE;
}
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
rv = inst->QueryInterface(aIID, aResult);
if (NS_FAILED(rv)) {
// We didn't get the right interface.
NS_ERROR("don't support the interface you want");
}
NS_IF_RELEASE(inst);
return rv;
}
nsresult nsHTTPHandlerFactory::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// The actual C functions for factory compliance.
// return the proper factory to the caller
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (! aFactory)
return NS_ERROR_NULL_POINTER;
//Who deletes this? Ask DP... TODO
nsHTTPHandlerFactory* factory = new nsHTTPHandlerFactory(aClass, aClassName, aProgID);
if (factory == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aFactory = factory;
return NS_OK;
}
extern "C" PR_IMPLEMENT(nsresult)
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv))
return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv))
return rv;
// register the factory
rv = compMgr->RegisterComponent(
nsIProtocolHandler::GetIID(),
"HTTP Handler",
NS_COMPONENT_NETSCAPE_NETWORK_PROTOCOLS "http",
aPath, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv))
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
extern "C" PR_IMPLEMENT(nsresult)
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv))
return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv))
return rv;
rv = compMgr->UnregisterComponent(kHTTPHandlerFactoryCID, aPath);
if (NS_FAILED(rv))
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

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

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIFactory.h"
class nsHTTPHandlerFactory : public nsIFactory
{
public:
nsHTTPHandlerFactory(const nsCID &aClass, const char* className, const char* progID);
// nsISupports methods
NS_DECL_ISUPPORTS
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
virtual ~nsHTTPHandlerFactory();
protected:
nsCID mClassID;
const char* mClassName;
const char* mProgID;
};

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

@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
//Note eventually this file moves to plughttp.dll. post DP work.
//
#include "nsHTTPInstance.h"
nsHTTPInstance::nsHTTPInstance(nsICoolURL* i_URL):
m_pURL(i_URL),
m_bConnected(PR_FALSE),
mRefCnt(0)
{
//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);
NS_METHOD
nsHTTPInstance::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(nsIProtocolInstance::GetIID())) {
*aInstancePtr = (void*) ((nsIProtocolInstance*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIHTTPInstance::GetIID())) {
*aInstancePtr = (void*) ((nsIHTTPInstance*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_RELEASE(nsHTTPInstance);
NS_METHOD
nsHTTPInstance::GetInputStream(nsIInputStream* *o_Stream)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_METHOD
nsHTTPInstance::Interrupt(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
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;
}

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

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsHTTPInstance_h_
#define _nsHTTPInstance_h_
#include "nsIHTTPInstance.h"
class nsICoolURL;
/*
The nsHTTPInstance class is an example implementation of a
protocol instnce that is active on a per-URL basis.
Currently this is being built with the Netlib dll. But after
the registration stuff that DP is working on gets completed
this will move to the HTTP lib.
-Gagan Saksena 02/25/99
*/
class nsHTTPInstance : public nsIHTTPInstance
{
public:
nsHTTPInstance(nsICoolURL* i_URL);
~nsHTTPInstance();
//Functions from nsISupports
NS_DECL_ISUPPORTS;
// Functions from nsIProtocolInstance
NS_METHOD GetInputStream( nsIInputStream* *o_Stream);
NS_METHOD Interrupt(void);
NS_METHOD Load(void);
// Functions from nsIHTTPInstance
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;
PRBool m_bConnected;
};
#endif /* _nsHTTPInstance_h_ */

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

@ -0,0 +1,79 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsHTTPRequest.h"
#include "nsIURI.h"
nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURI, HTTPMethod i_Method):
m_pURI(i_pURL),
m_Method(i_Method)
{
Build();
}
nsHTTPRequest::~nsHTTPRequest()
{
if (m_Request)
{
delete[] m_Request;
m_Request = 0;
}
}
NS_IMPL_ADDREF(nsHTTPRequest);
nsresult
nsHTTPRequest::Build()
{
return NS_OK;
}
nsresult
nsHTTPRequest::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(nsIHTTPRequest::GetIID())) {
*aInstancePtr = (void*) ((nsIHTTPRequest*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIHTTPCommonHeaders::GetIID())) {
*aInstancePtr = (void*) ((nsIHTTPCommonHeaders*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIHeader::GetIID())) {
*aInstancePtr = (void*) ((nsIHeader*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIProtocolHandler*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_RELEASE(nsHTTPRequest);

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

@ -0,0 +1,281 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsHTTPRequest_h_
#define _nsHTTPRequest_h_
#include "nsIHTTPCommonHeaders.h"
class nsIURI;
/*
The nsHTTPRequest class is the request object created for each HTTP
request before the connection. A request object may be cloned and
saved for later reuse.
This class is internal to the protocol handler implementation and
should theroetically not be used by the app or the core netlib.
-Gagan Saksena 03/29/99
*/
class nsHTTPRequest : public nsIHTTPCommonHeaders
{
public:
typedef enum _HTTPMethod {
DELETE, // Assure corresponding array set ok.
GET,
HEAD,
INDEX,
LINK,
OPTIONS,
POST,
PUT,
PATCH,
TRACE,
UNLINK
} HTTPMethod;
// Constructor and destructor
nsHTTPRequest(nsIURL* i_URL=0, HTTPMethod i_Method=GET);
virtual ~nsHTTPRequest();
// Methods from nsISupports
NS_DECL_ISUPPORTS
// Methods from nsIHeader
/*
Set or Get a header on the request. Note that for the first iteration
of this design, a set call will not replace an existing singleton
header (like User-Agent) So calling this will only append the
specified header to the request. Later on I would like to break
headers into singleton and multi-types... And then search and
replace an exising singleton header.
Similarly getting will for now only get the first occurence.
TODO change to get the list.
*/
NS_METHOD SetHeader(const char* i_Header, const char* i_Value);
NS_METHOD GetHeader(const char* i_Header, const char* *o_Value) const;
//This will be a no-op initially
NS_METHOD GetHeaderMultiple(
const char* i_Header,
const char** *o_ValueArray,
int o_Count) const;
// Methods from nsIHTTPCommonHeaders
NS_METHOD SetAllow(const char* i_Value);
NS_METHOD GetAllow(const char* *o_Value) const;
NS_METHOD SetContentBase(const char* i_Value);
NS_METHOD GetContentBase(const char* *o_Value) const;
NS_METHOD SetContentEncoding(const char* i_Value);
NS_METHOD GetContentEncoding(const char* *o_Value) const;
NS_METHOD SetContentLanguage(const char* i_Value);
NS_METHOD GetContentLanguage(const char* *o_Value) const;
NS_METHOD SetContentLength(const char* i_Value);
NS_METHOD GetContentLength(const char* *o_Value) const;
NS_METHOD SetContentLocation(const char* i_Value);
NS_METHOD GetContentLocation(const char* *o_Value) const;
NS_METHOD SetContentMD5(const char* i_Value);
NS_METHOD GetContentMD5(const char* *o_Value) const;
NS_METHOD SetContentRange(const char* i_Value);
NS_METHOD GetContentRange(const char* *o_Value) const;
NS_METHOD SetContentTransferEncoding(const char* i_Value);
NS_METHOD GetContentTransferEncoding(const char* *o_Value) const;
NS_METHOD SetContentType(const char* i_Value);
NS_METHOD GetContentType(const char* *o_Value) const;
NS_METHOD SetDerivedFrom(const char* i_Value);
NS_METHOD GetDerivedFrom(const char* *o_Value) const;
NS_METHOD SetETag(const char* i_Value);
NS_METHOD GetETag(const char* *o_Value) const;
NS_METHOD SetExpires(const char* i_Value);
NS_METHOD GetExpires(const char* *o_Value) const;
NS_METHOD SetLastModified(const char* i_Value);
NS_METHOD GetLastModified(const char* *o_Value) const;
/*
To set multiple link headers, call set link again.
*/
NS_METHOD SetLink(const char* i_Value);
NS_METHOD GetLink(const char* *o_Value) const;
NS_METHOD GetLinkMultiple(
const char** *o_ValueArray,
int count) const;
NS_METHOD SetTitle(const char* i_Value);
NS_METHOD GetTitle(const char* *o_Value) const;
NS_METHOD SetURI(const char* i_Value);
NS_METHOD GetURI(const char* *o_Value) const;
NS_METHOD SetVersion(const char* i_Value);
NS_METHOD GetVersion(const char* *o_Value) const;
// Common Transaction headers
NS_METHOD SetCC(const char* i_Value);
NS_METHOD GetCC(const char* *o_Value) const;
NS_METHOD SetConnection(const char* i_Value);
NS_METHOD GetConnection(const char* *o_Value) const;
NS_METHOD SetDate(const char* i_Value);
NS_METHOD GetDate(const char* *o_Value) const;
NS_METHOD SetPragma(const char* i_Value);
NS_METHOD GetPragma(const char* *o_Value) const;
NS_METHOD SetForwarded(const char* i_Value);
NS_METHOD GetForwarded(const char* *o_Value) const;
NS_METHOD SetMessageID(const char* i_Value);
NS_METHOD GetMessageID(const char* *o_Value) const;
NS_METHOD SetMIME(const char* i_Value);
NS_METHOD GetMIME(const char* *o_Value) const;
NS_METHOD SetTrailer(const char* i_Value);
NS_METHOD GetTrailer(const char* *o_Value) const;
NS_METHOD SetTransfer(const char* i_Value);
NS_METHOD GetTransfer(const char* *o_Value) const;
// Methods from nsIHTTPRequest
NS_METHOD SetAccept(const char* i_Types);
NS_METHOD GetAccept(const char* *o_Types) const;
NS_METHOD SetAcceptChar(const char* i_Chartype);
NS_METHOD GetAcceptChar(const char* *o_Chartype) const;
NS_METHOD SetAcceptEncoding(const char* i_Encoding);
NS_METHOD GetAcceptEncoding(const char* *o_Encoding) const;
NS_METHOD SetAcceptTransferEncoding(const char* i_Encoding);
NS_METHOD GetAcceptTransferEncoding(const char* *o_Encoding) const;
NS_METHOD SetAcceptLanguage(const char* i_Lang);
NS_METHOD GetAcceptLanguage(const char* *o_Lang) const;
NS_METHOD SetAuthentication(const char* i_Foo);
NS_METHOD GetAuthentication(const char* *o_Foo) const;
NS_METHOD SetExpect(const char* i_Expect);
NS_METHOD GetExpect(const char** o_Expect) const;
NS_METHOD SetFrom(const char* i_From);
NS_METHOD GetFrom(const char** o_From) const;
/*
This is the actual Host for connection. Not necessarily the
host in the url (as in the cases of proxy connection)
*/
NS_METHOD SetHost(const char* i_Host);
NS_METHOD GetHost(const char** o_Host) const;
NS_METHOD SetIfModifiedSince(const char* i_Value);
NS_METHOD GetIfModifiedSince(const char* *o_Value) const;
NS_METHOD SetIfMatch(const char* i_Value);
NS_METHOD GetIfMatch(const char* *o_Value) const;
NS_METHOD SetIfMatchAny(const char* i_Value);
NS_METHOD GetIfMatchAny(const char* *o_Value) const;
NS_METHOD SetIfNoneMatch(const char* i_Value);
NS_METHOD GetIfNoneMatch(const char* *o_Value) const;
NS_METHOD SetIfNoneMatchAny(const char* i_Value);
NS_METHOD GetIfNoneMatchAny(const char* *o_Value) const;
NS_METHOD SetIfRange(const char* i_Value);
NS_METHOD GetIfRange(const char* *o_Value) const;
NS_METHOD SetIfUnmodifiedSince(const char* i_Value);
NS_METHOD GetIfUnmodifiedSince(const char* *o_Value) const;
NS_METHOD SetMaxForwards(const char* i_Value);
NS_METHOD GetMaxForwards(const char* *o_Value) const;
/*
Range information for byte-range requests
*/
NS_METHOD SetRange(const char* i_Value);
NS_METHOD GetRange(const char* *o_Value) const;
NS_METHOD SetReferer(const char* i_Value);
NS_METHOD GetReferer(const char* *o_Value) const;
NS_METHOD SetUserAgent(const char* i_Value);
NS_METHOD GetUserAgent(const char* *o_Value) const;
// Finally our own methods...
NS_METHOD Clone(const nsHTTPRequest* *o_Request) const;
NS_METHOD SetMethod(HTTPMethod i_Method);
HTTPMethod GetMethod(void) const;
NS_METHOD SetPriority(); // TODO
NS_METHOD GetPriority(); //TODO
protected:
// Build the actual request string based on the settings.
NS_METHOD Build(void);
// Use a method string corresponding to the method.
const char* MethodToString(HTTPMethod i_Method=GET)
{
static const char[][] methods =
{
"DELETE",
"GET",
"HEAD",
"INDEX",
"LINK",
"OPTIONS",
"POST",
"PUT",
"PATCH",
"TRACE",
"UNLINK"
};
return methods[i_Method];
nsIURI* m_pURI;
HTTPMethod m_Method;
// The actual request string!
char* m_Request;
};
#endif /* _nsHTTPRequest_h_ */

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

@ -0,0 +1,39 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
IGNORE_MANIFEST=1
#------------------------------------------------------------------------
#
# Makefile to build the pluggable protocols
# If you decide to add any new directories here,
# make sure you have read the README.TXT file!
# -Gagan Saksena
#
#------------------------------------------------------------------------
DEPTH=..\..
include <$(DEPTH)\config\config.mak>
DIRS= \
file \
ftp \
http \
$(NULL)
include <$(DEPTH)\config\rules.mak>