not part of build. removing nunet r=brendan,darin
git-svn-id: svn://10.0.0.236/trunk@164240 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
NODEPEND=1
|
||||
IGNORE_MANIFEST = 1
|
||||
|
||||
MODULE = nunet
|
||||
|
||||
DIRS = src tests
|
||||
DEPTH= ..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
@@ -1,82 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
NODEPEND=1
|
||||
IGNORE_MANIFEST = 1
|
||||
|
||||
MODULE = nunet
|
||||
|
||||
DEPTH= ..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=nunet.dll
|
||||
PDBFILE=nunet.pdb
|
||||
MAPFILE=nunet.map
|
||||
DEFFILE=nunet.def
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\nsNetManager.obj \
|
||||
.\$(OBJDIR)\nsURL.obj \
|
||||
$(NULL)
|
||||
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME)
|
||||
|
||||
LCFLAGS=-DNETSCAPE -D_IMPL_NS_NET
|
||||
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(NULL)
|
||||
|
||||
LINCS=$(LINCS) -I. \
|
||||
-I..\..\public \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\security \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
$(NULL)
|
||||
|
||||
# clobber and clobber_all will remove the following garbage:
|
||||
GARBAGE = $(GARBAGE) _gen
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME) $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\nunet.lib $(DIST)\lib
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsNetManager.h"
|
||||
// For now libwww is here. TODO move to the protocol handler.
|
||||
//#include "WWWLib.h"
|
||||
|
||||
nsNetManager::nsNetManager()
|
||||
{
|
||||
// HTLibInit("NuNetlib", "1.0");
|
||||
}
|
||||
|
||||
nsNetManager::~nsNetManager()
|
||||
{
|
||||
// HTLibTerminate();
|
||||
}
|
||||
|
||||
void
|
||||
nsNetManager::Release()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsNetManager_h_
|
||||
#define _nsNetManager_h_
|
||||
|
||||
//#include "nsISupports.h"
|
||||
/*
|
||||
The nsNetManager class is the central service that
|
||||
runs the core nunet architecture. It handles all
|
||||
miscellaneous items like initializations, etc.
|
||||
|
||||
//TODO add the list of things this class does.
|
||||
-Gagan Saksena 03/23/99
|
||||
*/
|
||||
|
||||
class nsNetManager //: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
static nsNetManager* GetInstance(void)
|
||||
{
|
||||
static nsNetManager* pNetMgr = new nsNetManager();
|
||||
//pNetMgr->AddRef();
|
||||
return pNetMgr;
|
||||
}
|
||||
|
||||
void Release(void);
|
||||
|
||||
protected:
|
||||
nsNetManager(void);
|
||||
virtual ~nsNetManager();
|
||||
|
||||
};
|
||||
|
||||
#endif /* _nsNetManager_h_ */
|
||||
@@ -1,642 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//
|
||||
// TODOs for this file-
|
||||
// - Check error states returned from all occurences of ExtractPortFrom
|
||||
// - Grep on other TODOs...
|
||||
//
|
||||
|
||||
#include "nsURL.h"
|
||||
#include <stdlib.h>
|
||||
#include "plstr.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
static const PRInt32 DEFAULT_PORT = -1;
|
||||
|
||||
#define SET_POSITION(__part,__start,__length) \
|
||||
{ \
|
||||
m_Position[__part][0] = __start; \
|
||||
m_Position[__part][1] = __length; \
|
||||
}
|
||||
|
||||
|
||||
NS_NET
|
||||
nsICoolURL* CreateURL(const char* i_URL)
|
||||
{
|
||||
nsICoolURL* pReturn = new nsURL(i_URL);
|
||||
if (pReturn)
|
||||
pReturn->AddRef();
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
nsURL::nsURL(const char* i_URL):m_Port(DEFAULT_PORT),mRefCnt(0)
|
||||
{
|
||||
NS_PRECONDITION( (0 != i_URL), "No url string specified!");
|
||||
|
||||
if (i_URL)
|
||||
{
|
||||
m_URL = new char[PL_strlen(i_URL) + 1];
|
||||
if (m_URL)
|
||||
{
|
||||
PL_strcpy(m_URL, i_URL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_URL = new char[1];
|
||||
*m_URL = '\0';
|
||||
}
|
||||
|
||||
for (int i=0; i<TOTAL_PARTS; ++i)
|
||||
{
|
||||
for (int j=0; j<2; ++j)
|
||||
{
|
||||
m_Position[i][j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Parse();
|
||||
}
|
||||
|
||||
nsURL::~nsURL()
|
||||
{
|
||||
if (m_URL)
|
||||
{
|
||||
delete[] m_URL;
|
||||
m_URL = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsURL);
|
||||
|
||||
PRBool
|
||||
nsURL::Equals(const nsIURI* i_URI) const
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::Extract(const char* *o_OutputString, nsURL::Part i_id) const
|
||||
{
|
||||
int i = (int) i_id;
|
||||
if (o_OutputString)
|
||||
{
|
||||
*o_OutputString = new char(m_Position[i][1]+1);
|
||||
if (!*o_OutputString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
char* dest = (char*) *o_OutputString;
|
||||
char* src = m_URL + m_Position[i][0];
|
||||
|
||||
for (int j=0; j<m_Position[i][1]; ++j)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_URL_PARSING;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::ExtractPortFrom(int start, int length)
|
||||
{
|
||||
char* port = new char[length +1];
|
||||
if (!port)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
PL_strncpy(port, m_URL+start, length);
|
||||
*(port + length) = '\0';
|
||||
m_Port = atoi(port);
|
||||
delete[] port;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::GetStream(nsIInputStream* *o_InputStream)
|
||||
{
|
||||
NS_PRECONDITION( (0 != m_URL), "GetStream called on empty url!");
|
||||
nsresult result = NS_OK; // change to failure
|
||||
//OpenProtocolInstance and request the input stream
|
||||
nsIProtocolInstance* pi = 0;
|
||||
result = OpenProtocolInstance(&pi);
|
||||
|
||||
if (NS_OK != result)
|
||||
return result;
|
||||
return pi->GetInputStream(o_InputStream);
|
||||
}
|
||||
|
||||
nsresult nsURL::OpenProtocolInstance(nsIProtocolInstance* *o_ProtocolInstance)
|
||||
{
|
||||
const char* scheme =0;
|
||||
GetScheme(&scheme);
|
||||
// If the expected behaviour is to have http as the default scheme, a
|
||||
// caller must check that before calling this function. We will not
|
||||
// make any assumptions here.
|
||||
if (0 == scheme)
|
||||
return NS_ERROR_BAD_URL;
|
||||
|
||||
nsIProtocolHandler *pHandler=0;
|
||||
nsresult rv = nsComponentManager::CreateInstance(
|
||||
NS_COMPONENT_NETSCAPE_NETWORK_PROTOCOLS "http", // TODO replace!
|
||||
nsnull,
|
||||
nsIProtocolHandler::GetIID(),
|
||||
(void**)&pHandler);
|
||||
|
||||
return pHandler ? pHandler->GetProtocolInstance(this, o_ProtocolInstance) : rv;
|
||||
|
||||
#if 0 // For now hardcode it...
|
||||
if (0==PL_strcasecmp(scheme, "http"))
|
||||
{
|
||||
nsIHTTPHandler* pHandler= 0;
|
||||
// TODO This has to change to Factory interface
|
||||
//if (NS_OK == CreateOrGetHTTPHandler(&pHandler))
|
||||
{
|
||||
if (pHandler)
|
||||
{
|
||||
return pHandler->GetProtocolInstance(this, o_ProtocolInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// This code will need thorough testing. A lot of this has to do with
|
||||
// usability and expected behaviour when a user types something in the
|
||||
// location bar.
|
||||
nsresult nsURL::Parse(void)
|
||||
{
|
||||
NS_PRECONDITION( (0 != m_URL), "Parse called on empty url!");
|
||||
if (!m_URL)
|
||||
{
|
||||
return NS_ERROR_URL_PARSING;
|
||||
}
|
||||
|
||||
//Remember to remove leading/trailing spaces, etc. TODO
|
||||
int len = PL_strlen(m_URL);
|
||||
static const char delimiters[] = "/:@"; //this order is optimized.
|
||||
char* brk = PL_strpbrk(m_URL, delimiters);
|
||||
char* lastbrk = brk;
|
||||
if (brk)
|
||||
{
|
||||
switch (*brk)
|
||||
{
|
||||
case '/' :
|
||||
// If the URL starts with a slash then everything is a path
|
||||
if (brk == m_URL)
|
||||
{
|
||||
SET_POSITION(PATH, 0, len);
|
||||
return NS_OK;
|
||||
}
|
||||
else // The first part is host, so its host/path
|
||||
{
|
||||
SET_POSITION(HOST, 0, (brk - m_URL));
|
||||
SET_POSITION(PATH, (brk - m_URL), (len - (brk - m_URL)));
|
||||
return NS_OK;
|
||||
}
|
||||
break;
|
||||
case ':' :
|
||||
// If the first colon is followed by // then its definitely a spec
|
||||
if ((*(brk+1) == '/') && (*(brk+2) == '/')) // e.g. http://
|
||||
{
|
||||
SET_POSITION(SCHEME, 0, (brk - m_URL));
|
||||
lastbrk = brk+3;
|
||||
brk = PL_strpbrk(lastbrk, delimiters);
|
||||
if (brk)
|
||||
{
|
||||
switch (*brk)
|
||||
{
|
||||
case '/' : // standard case- http://host/path
|
||||
SET_POSITION(HOST, (lastbrk - m_URL), (brk - lastbrk));
|
||||
SET_POSITION(PATH, (brk - m_URL), (len - (brk - m_URL)));
|
||||
return NS_OK;
|
||||
break;
|
||||
case ':' :
|
||||
{
|
||||
// It could be http://user:pass@host/path or http://host:port/path
|
||||
// For the first case, there has to be an at after this colon, so...
|
||||
char* atSign = PL_strchr(brk, '@');
|
||||
if (atSign)
|
||||
{
|
||||
SET_POSITION(PREHOST, (lastbrk - m_URL), (atSign - lastbrk));
|
||||
brk = PL_strpbrk(atSign+1, "/:");
|
||||
if (brk) // http://user:pass@host:port/path or http://user:pass@host/path
|
||||
{
|
||||
SET_POSITION(HOST, (atSign+1 - m_URL), (brk - (atSign+1)));
|
||||
if (*brk == '/')
|
||||
{
|
||||
SET_POSITION(PATH, (brk - m_URL), len - (brk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // we have a port since (brk == ':')
|
||||
{
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strchr(lastbrk, '/');
|
||||
if (brk) // http://user:pass@host:port/path
|
||||
{
|
||||
ExtractPortFrom((lastbrk - m_URL), (brk-lastbrk));
|
||||
SET_POSITION(PATH, (brk-m_URL), len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // http://user:pass@host:port
|
||||
{
|
||||
ExtractPortFrom((lastbrk - m_URL), len - (lastbrk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else // its just http://user:pass@host
|
||||
{
|
||||
SET_POSITION(HOST, (atSign+1 - m_URL), len - (atSign+1 - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // definitely the port option, i.e. http://host:port/path
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), (brk-lastbrk));
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strchr(lastbrk, '/');
|
||||
if (brk) // http://host:port/path
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),(brk-lastbrk));
|
||||
SET_POSITION(PATH, (brk-m_URL), len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // http://host:port
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '@' :
|
||||
// http://user@host...
|
||||
{
|
||||
SET_POSITION(PREHOST, (lastbrk-m_URL), (brk-lastbrk));
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strpbrk(lastbrk, ":/");
|
||||
if (brk)
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), (brk - lastbrk));
|
||||
if (*brk == ':') // http://user@host:port...
|
||||
{
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strchr(lastbrk, '/');
|
||||
if (brk) // http://user@host:port/path
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),(brk-lastbrk));
|
||||
SET_POSITION(PATH, (brk-m_URL), len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // http://user@host:port
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
else // (*brk == '/') so no port just path i.e. http://user@host/path
|
||||
{
|
||||
SET_POSITION(PATH, (brk - m_URL), len - (brk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // its just http://user@host
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk+1 - m_URL), len - (lastbrk+1 - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
default: NS_POSTCONDITION(0, "This just can't be!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else // everything else is a host, as in http://host
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk - m_URL), len - (lastbrk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
else // host:port...
|
||||
{
|
||||
SET_POSITION(HOST, 0, (brk - m_URL));
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strpbrk(lastbrk, delimiters);
|
||||
if (brk)
|
||||
{
|
||||
switch (*brk)
|
||||
{
|
||||
case '/' : // The path, so its host:port/path
|
||||
ExtractPortFrom(lastbrk-m_URL, brk-lastbrk);
|
||||
SET_POSITION(PATH, brk- m_URL, len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
break;
|
||||
case ':' :
|
||||
return NS_ERROR_URL_PARSING;
|
||||
break;
|
||||
case '@' :
|
||||
// This is a special case of user:pass@host... so
|
||||
// Cleanout our earliar knowledge of host
|
||||
SET_POSITION(HOST, -1, -1);
|
||||
|
||||
SET_POSITION(PREHOST, 0, (brk-m_URL));
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strpbrk(lastbrk, ":/");
|
||||
if (brk)
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), (brk-lastbrk));
|
||||
if (*brk == ':') // user:pass@host:port...
|
||||
{
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strchr(lastbrk, '/');
|
||||
if (brk) // user:pass@host:port/path
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),(brk-lastbrk));
|
||||
SET_POSITION(PATH, (brk-m_URL), len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // user:pass@host:port
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // (*brk == '/') so user:pass@host/path
|
||||
{
|
||||
SET_POSITION(PATH, (brk - m_URL), len - (brk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // its user:pass@host so everthing else is just the host
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
break;
|
||||
default: NS_POSTCONDITION(0, "This just can't be!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // Everything else is just the port
|
||||
{
|
||||
ExtractPortFrom(lastbrk-m_URL, len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '@' :
|
||||
//Everything before the @ is the prehost stuff
|
||||
SET_POSITION(PREHOST, 0, brk-m_URL);
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strpbrk(lastbrk, ":/");
|
||||
if (brk)
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), (brk-lastbrk));
|
||||
if (*brk == ':') // user@host:port...
|
||||
{
|
||||
lastbrk = brk+1;
|
||||
brk = PL_strchr(lastbrk, '/');
|
||||
if (brk) // user@host:port/path
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),(brk-lastbrk));
|
||||
SET_POSITION(PATH, (brk-m_URL), len - (brk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
else // user@host:port
|
||||
{
|
||||
ExtractPortFrom((lastbrk-m_URL),len - (lastbrk-m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // (*brk == '/') so user@host/path
|
||||
{
|
||||
SET_POSITION(PATH, (brk - m_URL), len - (brk - m_URL));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else // its user@host so everything else is just the host
|
||||
{
|
||||
SET_POSITION(HOST, (lastbrk-m_URL), (len - (lastbrk-m_URL)));
|
||||
return NS_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NS_POSTCONDITION(0, "This just can't be!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // everything is a host
|
||||
{
|
||||
SET_POSITION(HOST, 0, len);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsURL::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(nsICoolURL::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICoolURL*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIURI::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIURI*)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(nsURL);
|
||||
|
||||
nsresult
|
||||
nsURL::SetHost(const char* i_Host)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::SetPath(const char* i_Path)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::SetPort(PRInt32 i_Port)
|
||||
{
|
||||
if (m_Port != i_Port)
|
||||
{
|
||||
m_Port = i_Port;
|
||||
if (DEFAULT_PORT == m_Port)
|
||||
{
|
||||
//Just REMOVE the earliar one.
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Insert the string equivalent
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
}
|
||||
Parse();
|
||||
}
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::SetPreHost(const char* i_PreHost)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsURL::SetScheme(const char* i_Scheme)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Eeeks!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult
|
||||
nsURL::DebugString(const char* *o_String) const
|
||||
{
|
||||
if (!m_URL)
|
||||
return NS_OK;
|
||||
const char* tempBuff = 0;
|
||||
char* tmp = new char[PL_strlen(m_URL) + 64];
|
||||
char* tmp2 = tmp;
|
||||
for (int i=PL_strlen(m_URL)+64; i>0 ; --i)
|
||||
*tmp2++ = '\0';
|
||||
/*///
|
||||
PL_strcpy(tmp, "m_URL= ");
|
||||
PL_strcat(tmp, m_URL);
|
||||
|
||||
GetScheme(&tempBuff);
|
||||
PL_strcat(tmp, "\nScheme= ");
|
||||
PL_strcat(tmp, tempBuff);
|
||||
|
||||
GetPreHost(&tempBuff);
|
||||
PL_strcat(tmp, "\nPreHost= ");
|
||||
PL_strcat(tmp, tempBuff);
|
||||
|
||||
GetHost(&tempBuff);
|
||||
PL_strcat(tmp, "\nHost= ");
|
||||
PL_strcat(tmp, tempBuff);
|
||||
|
||||
char* tempPort = new char[6];
|
||||
if (tempPort)
|
||||
{
|
||||
itoa(m_Port, tempPort, 10);
|
||||
PL_strcat(tmp, "\nPort= ");
|
||||
PL_strcat(tmp, tempPort);
|
||||
delete[] tempPort;
|
||||
}
|
||||
else
|
||||
PL_strcat(tmp, "\nPort couldn't be conv'd to string!");
|
||||
|
||||
GetPath(&tempBuff);
|
||||
PL_strcat(tmp, "\nPath= ");
|
||||
PL_strcat(tmp, tempBuff);
|
||||
PL_strcat(tmp, "\n");
|
||||
/*///
|
||||
char delimiter[] = ",";
|
||||
#define TEMP_AND_DELIMITER PL_strcat(tmp, tempBuff); \
|
||||
PL_strcat(tmp, delimiter)
|
||||
|
||||
PL_strcpy(tmp, m_URL);
|
||||
PL_strcat(tmp, "\n");
|
||||
|
||||
GetScheme(&tempBuff);
|
||||
TEMP_AND_DELIMITER;
|
||||
|
||||
GetPreHost(&tempBuff);
|
||||
TEMP_AND_DELIMITER;
|
||||
|
||||
GetHost(&tempBuff);
|
||||
TEMP_AND_DELIMITER;
|
||||
|
||||
char* tempPort = new char[6];
|
||||
if (tempPort)
|
||||
{
|
||||
itoa(m_Port, tempPort, 10);
|
||||
PL_strcat(tmp, tempPort);
|
||||
PL_strcat(tmp, delimiter);
|
||||
delete[] tempPort;
|
||||
}
|
||||
else
|
||||
PL_strcat(tmp, "\nPort couldn't be conv'd to string!");
|
||||
|
||||
GetPath(&tempBuff);
|
||||
PL_strcat(tmp, tempBuff);
|
||||
PL_strcat(tmp, "\n");
|
||||
|
||||
//*///
|
||||
*o_String = tmp;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // DEBUG
|
||||
@@ -1,229 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsURL_h_
|
||||
#define _nsURL_h_
|
||||
|
||||
/*
|
||||
The nsURL class holds the default implementation of the nsICoolURL class.
|
||||
For explaination on the implementation see -
|
||||
|
||||
http://www.w3.org/Addressing/URL/url-spec.txt
|
||||
and the headers for nsICoolURL.h and nsIURI.h
|
||||
|
||||
- Gagan Saksena
|
||||
*/
|
||||
|
||||
#include "nsICoolURL.h"
|
||||
|
||||
class nsURL : public nsICoolURL
|
||||
{
|
||||
|
||||
public:
|
||||
//Constructor
|
||||
nsURL(const char* i_URL);
|
||||
|
||||
//Functions from nsISupports
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
//Functions from nsIURI
|
||||
//Core parsing functions.
|
||||
/*
|
||||
The Scheme is the protocol that this URL refers to.
|
||||
*/
|
||||
NS_METHOD GetScheme(const char* *o_Scheme) const;
|
||||
NS_METHOD SetScheme(const char* i_Scheme);
|
||||
|
||||
/*
|
||||
The PreHost portion includes elements like the optional
|
||||
username:password, or maybe other scheme specific items.
|
||||
*/
|
||||
NS_METHOD GetPreHost(const char* *o_PreHost) const;
|
||||
NS_METHOD SetPreHost(const char* i_PreHost);
|
||||
|
||||
/*
|
||||
The Host is the internet domain name to which this URL refers.
|
||||
Note that it could be an IP address as well.
|
||||
*/
|
||||
NS_METHOD GetHost(const char* *o_Host) const;
|
||||
NS_METHOD SetHost(const char* i_Host);
|
||||
|
||||
/*
|
||||
A return value of -1 indicates that no port value is set and the
|
||||
implementor of the specific scheme will use its default port.
|
||||
Similarly setting a value of -1 indicates that the default is to be used.
|
||||
Thus as an example-
|
||||
for HTTP, Port 80 is same as a return value of -1.
|
||||
However after setting a port (even if its default), the port number will
|
||||
appear in the ToString function.
|
||||
*/
|
||||
NS_METHOD_(PRInt32) GetPort(void) const;
|
||||
NS_METHOD SetPort(PRInt32 i_Port);
|
||||
|
||||
/*
|
||||
Note that the path includes the leading '/' Thus if no path is
|
||||
available the GetPath will return a "/"
|
||||
For SetPath if none is provided, one would be prefixed to the path.
|
||||
*/
|
||||
NS_METHOD GetPath(const char* *o_Path) const;
|
||||
NS_METHOD SetPath(const char* i_Path);
|
||||
|
||||
//Functions from nsICoolURL.h
|
||||
/*
|
||||
Note: The GetStream function also opens a connection using
|
||||
the available information in the URL. This is the same as
|
||||
calling OpenInputStream on the connection returned from
|
||||
OpenProtocolInstance.
|
||||
*/
|
||||
NS_METHOD GetStream(nsIInputStream* *o_InputStream);
|
||||
|
||||
/*
|
||||
The OpenProtocolInstance method sets up the connection as decided by the
|
||||
protocol implementation. This may then be used to get various
|
||||
connection specific details like the input and the output streams
|
||||
associated with the connection, or the header information by querying
|
||||
on the connection type which will be protocol specific.
|
||||
*/
|
||||
NS_METHOD OpenProtocolInstance(nsIProtocolInstance* *o_ProtocolInstance);
|
||||
|
||||
|
||||
//Other utility functions
|
||||
/*
|
||||
Note that this comparison is only on char* level. Cast nsIURL to
|
||||
the scheme specific URL to do a more thorough check. For example--
|
||||
in HTTP-
|
||||
http://foo.com:80 == http://foo.com
|
||||
but this function through nsIURL alone will not return equality.
|
||||
*/
|
||||
NS_METHOD_(PRBool) Equals(const nsIURI* i_URI) const;
|
||||
|
||||
/*
|
||||
Writes a string representation of the URL.
|
||||
*/
|
||||
NS_METHOD ToString(const char* *o_URLString) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_METHOD DebugString(const char* *o_URLString) const;
|
||||
#endif //DEBUG
|
||||
|
||||
protected:
|
||||
|
||||
//Called only from Release
|
||||
virtual ~nsURL();
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SCHEME,
|
||||
PREHOST,
|
||||
HOST,
|
||||
PATH,
|
||||
TOTAL_PARTS // Must always be the last one.
|
||||
} Part;
|
||||
|
||||
/*
|
||||
Parses the portions of the URL into individual pieces
|
||||
like spec, prehost, host, path etc.
|
||||
*/
|
||||
NS_METHOD Parse();
|
||||
|
||||
/*
|
||||
Extract a portion from the given part id.
|
||||
*/
|
||||
NS_METHOD Extract(const char* *o_OutputString, Part i_id) const;
|
||||
|
||||
/*
|
||||
This holds the offsets and the lengths of each part.
|
||||
Optimizes on storage and speed.
|
||||
*/
|
||||
int m_Position[TOTAL_PARTS][2];
|
||||
|
||||
char* m_URL;
|
||||
PRInt32 m_Port;
|
||||
private:
|
||||
NS_METHOD ExtractPortFrom(int start, int length);
|
||||
};
|
||||
|
||||
inline
|
||||
NS_METHOD
|
||||
nsURL::GetHost(const char* *o_Host) const
|
||||
{
|
||||
return Extract(o_Host, HOST);
|
||||
}
|
||||
|
||||
inline
|
||||
NS_METHOD
|
||||
nsURL::GetScheme(const char* *o_Scheme) const
|
||||
{
|
||||
return Extract(o_Scheme, SCHEME);
|
||||
}
|
||||
|
||||
inline
|
||||
NS_METHOD
|
||||
nsURL::GetPreHost(const char* *o_PreHost) const
|
||||
{
|
||||
return Extract(o_PreHost, PREHOST);
|
||||
}
|
||||
|
||||
inline
|
||||
NS_METHOD_(PRInt32)
|
||||
nsURL::GetPort() const
|
||||
{
|
||||
return m_Port;
|
||||
}
|
||||
|
||||
inline
|
||||
NS_METHOD
|
||||
nsURL::GetPath(const char* *o_Path) const
|
||||
{
|
||||
return Extract(o_Path, PATH);
|
||||
}
|
||||
|
||||
inline
|
||||
NS_METHOD
|
||||
nsURL::ToString(const char* *o_URLString) const
|
||||
{
|
||||
*o_URLString = m_URL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Possible bad url passed.
|
||||
#define NS_ERROR_URL_PARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 100);
|
||||
#define NS_ERROR_BAD_URL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 101);
|
||||
|
||||
#endif /* _nsURL_h_ */
|
||||
@@ -1,38 +0,0 @@
|
||||
; ***** BEGIN LICENSE BLOCK *****
|
||||
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;
|
||||
; The contents of this file are subject to the Mozilla Public License Version
|
||||
; 1.1 (the "License"); you may not use this file except in compliance with
|
||||
; the License. You may obtain a copy of the License at
|
||||
; http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
; for the specific language governing rights and limitations under the
|
||||
; License.
|
||||
;
|
||||
; The Original Code is mozilla.org code.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; Netscape Communications Corporation.
|
||||
; Portions created by the Initial Developer are Copyright (C) 1998
|
||||
; the Initial Developer. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s):
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the terms of
|
||||
; either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
; in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
; of those above. If you wish to allow use of your version of this file only
|
||||
; under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
; use your version of this file under the terms of the MPL, indicate your
|
||||
; decision by deleting the provisions above and replace them with the notice
|
||||
; and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
; the provisions above, a recipient may use your version of this file under
|
||||
; the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;
|
||||
; ***** END LICENSE BLOCK *****
|
||||
|
||||
LIBRARY nunet.dll
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
NODEPEND=1
|
||||
IGNORE_MANIFEST = 1
|
||||
|
||||
MODULE = urltest
|
||||
|
||||
DEPTH= ..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
|
||||
EXENAME=urltest
|
||||
PDBFILE=nunettest.pdb
|
||||
MAPFILE=nunettest.map
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\urltest.obj \
|
||||
$(NULL)
|
||||
|
||||
PROGRAM=.\$(OBJDIR)\$(EXENAME).EXE
|
||||
|
||||
LCFLAGS=-DNETSCAPE
|
||||
LLIBS=$(LLIBS) \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\nunet.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\plc3.lib
|
||||
|
||||
LINCS=$(LINCS) -I. \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\nunet \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\xpcom
|
||||
|
||||
# clobber and clobber_all will remove the following garbage:
|
||||
GARBAGE = $(GARBAGE) _gen
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(EXENAME).exe
|
||||
@@ -1,333 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "plstr.h"
|
||||
#include "plevent.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsXPComCIID.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsICoolURL.h"
|
||||
#include "nsINetService.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#include "nsMacRepository.h"
|
||||
#else
|
||||
#define NETLIB_DLL "libnetlib.so"
|
||||
#define XPCOM_DLL "libxpcom.so"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define CIDs...
|
||||
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
// Define IIDs...
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
//NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
|
||||
|
||||
#ifdef XP_UNIX
|
||||
extern "C" char *fe_GetConfigDir(void) {
|
||||
printf("XXX: return /tmp for fe_GetConfigDir\n");
|
||||
return strdup("/tmp");
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#if 0 // Enable after the stream listener interface is cleared up.
|
||||
class TestConsumer : public nsIStreamListener
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
TestConsumer();
|
||||
|
||||
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info);
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 Progress, PRUint32 ProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length);
|
||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg);
|
||||
|
||||
protected:
|
||||
~TestConsumer();
|
||||
};
|
||||
|
||||
|
||||
TestConsumer::TestConsumer()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
||||
NS_IMPL_ISUPPORTS(TestConsumer,kIStreamListenerIID);
|
||||
|
||||
|
||||
TestConsumer::~TestConsumer()
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer is being deleted...\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP TestConsumer::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* info)
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::GetBindInfo: URL: %p\n", aURL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TestConsumer::OnProgress(nsIURL* aURL, PRUint32 Progress,
|
||||
PRUint32 ProgressMax)
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::OnProgress: URL: %p - %d of total %d\n", aURL, Progress, ProgressMax);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TestConsumer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::OnStatus: ");
|
||||
nsAutoString str(aMsg);
|
||||
char* c = str.ToNewCString();
|
||||
fputs(c, stdout);
|
||||
free(c);
|
||||
fputs("\n", stdout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP TestConsumer::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::OnStartBinding: URL: %p, Content type: %s\n", aURL, aContentType);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP TestConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUint32 length)
|
||||
{
|
||||
PRUint32 len;
|
||||
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::OnDataAvailable: URL: %p, %d bytes available...\n", aURL, length);
|
||||
}
|
||||
|
||||
do {
|
||||
nsresult err;
|
||||
char buffer[80];
|
||||
PRUint32 i;
|
||||
|
||||
err = pIStream->Read(buffer, 0, 80, &len);
|
||||
if (err == NS_OK) {
|
||||
for (i=0; i<len; i++) {
|
||||
putchar(buffer[i]);
|
||||
}
|
||||
}
|
||||
} while (len > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP TestConsumer::OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg)
|
||||
{
|
||||
if (bTraceEnabled) {
|
||||
printf("\n+++ TestConsumer::OnStopBinding... URL: %p status: %d\n", aURL, status);
|
||||
}
|
||||
|
||||
if (NS_FAILED(status)) {
|
||||
const char* url;
|
||||
aURL->GetSpec(&url);
|
||||
|
||||
printf("Unable to load URL %s\n", url);
|
||||
}
|
||||
/* The document has been loaded, so drop out of the message pump... */
|
||||
urlLoaded = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // 0 - enabled after streamlistener is fixed.
|
||||
|
||||
nsresult ReadStreamSynchronously(nsIInputStream* aIn)
|
||||
{
|
||||
nsresult rv;
|
||||
char buffer[1024];
|
||||
|
||||
if (nsnull != aIn) {
|
||||
PRUint32 len;
|
||||
|
||||
do {
|
||||
PRUint32 i;
|
||||
|
||||
rv = aIn->Read(buffer, sizeof(buffer), &len);
|
||||
for (i=0; i<len; i++) {
|
||||
putchar(buffer[i]);
|
||||
}
|
||||
} while (len > 0);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int testURL(const char* pURL=0);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
nsAutoString url_address;
|
||||
// char buf[256];
|
||||
// nsIStreamListener *pConsumer;
|
||||
nsIEventQueueService* pEventQService;
|
||||
// nsIURL *pURL;
|
||||
nsresult result;
|
||||
int i;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("urltest: <URL> \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_InitXPCOM(nsnull);
|
||||
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, "./components");
|
||||
|
||||
testURL(argv[1]);
|
||||
return 0;
|
||||
#if 0
|
||||
nsRepository::RegisterComponent(
|
||||
kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsRepository::RegisterComponent(
|
||||
kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
pEventQService = nsnull;
|
||||
result = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||
kIEventQueueServiceIID,
|
||||
(nsISupports **)&pEventQService);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
// XXX: What if this fails?
|
||||
result = pEventQService->CreateThreadEventQueue();
|
||||
}
|
||||
|
||||
for (i=1; i < argc; i++) {
|
||||
if (PL_strcasecmp(argv[i], "-all") == 0) {
|
||||
testURL(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
testURL(argv[i]);
|
||||
}
|
||||
|
||||
if (nsnull != pEventQService) {
|
||||
pEventQService->DestroyThreadEventQueue();
|
||||
nsServiceManager::ReleaseService(kEventQueueServiceCID, pEventQService);
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int testURL(const char* i_pURL)
|
||||
{
|
||||
const char* temp;
|
||||
if (i_pURL)
|
||||
{
|
||||
nsICoolURL* pURL = CreateURL(i_pURL);
|
||||
pURL->DebugString(&temp);
|
||||
cout << temp <<endl;
|
||||
|
||||
nsIInputStream* is = 0;
|
||||
if (NS_OK == pURL->GetStream(&is))
|
||||
{
|
||||
ReadStreamSynchronously(is);
|
||||
}
|
||||
|
||||
pURL->Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int tests = 8;
|
||||
const char* url[tests] =
|
||||
{
|
||||
"http://username:password@hostname.com:80/pathname/./more/stuff/../path",
|
||||
"username@host:8080/path",
|
||||
"http://gagan/",
|
||||
"host:port/netlib", //port should now be 0
|
||||
"", //empty string
|
||||
"mailbox:///foo", // No host specified path should be /foo
|
||||
"user:pass@hostname.edu:80/pathname", //this is always user:pass and not http:user
|
||||
"username:password@hostname:80/pathname"
|
||||
};
|
||||
|
||||
for (int i = 0; i< tests; ++i)
|
||||
{
|
||||
nsICoolURL* pURL = CreateURL(url[i]);
|
||||
pURL->DebugString(&temp);
|
||||
cout << temp << endl;
|
||||
pURL->Release();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
#!gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
DEPTH=..
|
||||
|
||||
DIRS= \
|
||||
public \
|
||||
base \
|
||||
protocols \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
INCLUDE = $(INCLUDE)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
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
|
||||
@@ -1,50 +0,0 @@
|
||||
#!gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile to build the pluggable HTTP
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
DEPTH=..\..\..
|
||||
DIRS= \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,91 +0,0 @@
|
||||
#!gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
|
||||
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__
|
||||
@@ -1,128 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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)
|
||||
{
|
||||
*o_HTTPHandler = nsHTTPHandler::GetInstance();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -1,107 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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_ */
|
||||
@@ -1,214 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
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;
|
||||
|
||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
|
||||
// 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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_ */
|
||||
@@ -1,59 +0,0 @@
|
||||
#!gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
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 \
|
||||
http \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
NODEPEND=1
|
||||
IGNORE_MANIFEST = 1
|
||||
|
||||
MODULE = nunet
|
||||
EXPORTS = \
|
||||
nsICoolURL.h \
|
||||
nsIHTTPHandler.h \
|
||||
nsIHTTPInstance.h \
|
||||
nsIProtocolInstance.h \
|
||||
nsIProtocolHandler.h \
|
||||
nsIProxy.h \
|
||||
nsIURI.h \
|
||||
$(NULL)
|
||||
|
||||
DEPTH= ..\..\
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsICoolURL_h_
|
||||
#define _nsICoolURL_h_
|
||||
|
||||
/*
|
||||
The nsICoolURL class is an interface to the URL behaviour.
|
||||
This follows the URL spec at-
|
||||
|
||||
http://www.w3.org/Addressing/URL/url-spec.txt
|
||||
|
||||
For the purpose of this class, here is the most elaborate form of a URL
|
||||
and its corresponding parts-
|
||||
|
||||
ftp://username:password@hostname:portnumber/pathname
|
||||
\ / \ / \ / \ /\ /
|
||||
- --------------- ------ -------- -------
|
||||
| | | | |
|
||||
| | | | Path
|
||||
| | | Port
|
||||
| | Host
|
||||
| PreHost
|
||||
Scheme
|
||||
|
||||
The URL class extends the URI behaviour by providing a mechanism
|
||||
for consumers to retreive (and on protocol specific levels put)
|
||||
documents defined by the URI.
|
||||
|
||||
Functions missing from this file are the stream listener portions
|
||||
for asynch operations. TODO.
|
||||
|
||||
Please send me a mail before you add anything to this file.
|
||||
Thanks!- Gagan Saksena
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIProtocolInstance.h"
|
||||
|
||||
class nsICoolURL : public nsIURI
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//Core action functions
|
||||
/*
|
||||
Note: The GetStream function also opens a connection using
|
||||
the available information in the URL. This is the same as
|
||||
calling OpenInputStream on the connection returned from
|
||||
OpenProtocolInstance. Note that this stream doesn't contain any
|
||||
header information either.
|
||||
*/
|
||||
NS_IMETHOD GetStream(nsIInputStream* *o_InputStream) = 0;
|
||||
|
||||
#if 0 //Will go away...
|
||||
/*
|
||||
The GetDocument function BLOCKS till the data is made available
|
||||
or an error condition is encountered. The return type is the overall
|
||||
success status which depends on the protocol implementation.
|
||||
Its just a convenience function that internally sets up a temp
|
||||
stream in memory and buffers everything. Note that this
|
||||
mechanism strips off the headers and only the raw data is
|
||||
copied to the passed string.
|
||||
|
||||
TODO - return status?
|
||||
*/
|
||||
NS_IMETHOD GetDocument(const char* *o_Data) = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
The OpenProtocolInstance method sets up the connection as decided by the
|
||||
protocol implementation. This may then be used to get various
|
||||
connection specific details like the input and the output streams
|
||||
associated with the connection, or the header information by querying
|
||||
on the connection type which will be protocol specific.
|
||||
*/
|
||||
NS_IMETHOD OpenProtocolInstance(nsIProtocolInstance* *o_ProtocolInstance) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD DebugString(const char* *o_URLString) const=0;
|
||||
#endif //DEBUG
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {6DA32F00-BD64-11d2-B00F-006097BFC036}
|
||||
static const nsIID NS_ICOOLURL_IID =
|
||||
{ 0x6da32f00, 0xbd64, 0x11d2, { 0xb0, 0xf, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
return NS_ICOOLURL_IID;
|
||||
};
|
||||
};
|
||||
|
||||
// Should change to NS_METHOD CreateURL(nsICoolURL* *o_URL, const char* i_URL)
|
||||
// and be placed where?
|
||||
extern NS_NET
|
||||
nsICoolURL* CreateURL(const char* i_URL);
|
||||
|
||||
|
||||
#endif /* _nsICoolURL_h_ */
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIHTTPHandler_h_
|
||||
#define _nsIHTTPHandler_h_
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
/*
|
||||
The nsIHTTPHandler class is the bare minimum interface expected for
|
||||
an HTTP handler. The set of interfaces this handler is derived from decides
|
||||
the expected behaviour. For example another HTTPHandler may decide
|
||||
not to use proxies or to support proxy connections, in which case
|
||||
it will not derive from nsIProxy.
|
||||
|
||||
-Gagan Saksena 02/25/99
|
||||
*/
|
||||
|
||||
class nsIHTTPHandler : public nsIProtocolHandler//, public nsIProxy
|
||||
// TODO should also have caching interfaces
|
||||
// as well as security stuff, etc.
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
GetDefaultPort returns the default port associated with this
|
||||
protocol.
|
||||
*/
|
||||
NS_METHOD_(PRInt32) GetDefaultPort(void) const
|
||||
{
|
||||
static const PRInt32 defaultPort = 80;
|
||||
return defaultPort;
|
||||
};
|
||||
|
||||
/*
|
||||
The GetScheme function uniquely identifies the scheme this handler
|
||||
is associated with.
|
||||
*/
|
||||
NS_METHOD GetScheme(const char* *o_Scheme) const
|
||||
{
|
||||
static const char* scheme = "http";
|
||||
*o_Scheme = scheme;
|
||||
return NS_OK;
|
||||
};
|
||||
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {A3BE3AF0-CD2D-11d2-B013-006097BFC036}
|
||||
static const nsIID NS_IHTTPHandler_IID =
|
||||
{ 0xa3be3af0, 0xcd2d, 0x11d2, { 0xb0, 0x13, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
return NS_IHTTPHandler_IID;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
//Possible errors
|
||||
#define NS_ERROR_BAD_REQUEST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 200);
|
||||
|
||||
// Create (or get) HTTP Handler
|
||||
extern NS_METHOD CreateOrGetHTTPHandler(nsIHTTPHandler* *o_HTTPHandler);
|
||||
|
||||
#endif /* _nsIHTTPHandler_h_ */
|
||||
@@ -1,136 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIHTTPInstance_h_
|
||||
#define _nsIHTTPInstance_h_
|
||||
|
||||
#include "nsIProtocolInstance.h"
|
||||
|
||||
typedef enum {
|
||||
HTTP_ZERO_NINE, // HTTP/0.9
|
||||
HTTP_ONE_ZERO, // HTTP/1.0
|
||||
HTTP_ONE_ONE // HTTP/1.1
|
||||
} HTTPVersion;
|
||||
|
||||
/*
|
||||
The nsIHTTPInstance class is the interface to an intance
|
||||
of the HTTP that acts on a per URL basis.
|
||||
|
||||
There are a ton of things that an instance should hold
|
||||
but due to the lack of time I am letting those things
|
||||
be used from the old code base. Someday someone will
|
||||
step in and get rid of old code and put things here
|
||||
like socket, other connection data, etc.
|
||||
|
||||
-Gagan Saksena 03/06/99
|
||||
*/
|
||||
|
||||
class nsIHTTPInstance : public nsIProtocolInstance
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
#if 0 // TODO Past N2 things. As much as I want it now.... so much
|
||||
// to do and so little resources. Argh...!
|
||||
// Will have to write nsIHTTPRequest and nsIHTTPResponse classes
|
||||
// both derived from nsIHeader. The response's setheader should
|
||||
// return NS_ERROR_ARE_YOU_NUTS?
|
||||
|
||||
// TODO think if the Request/Response should move out in
|
||||
// its own interface. Would other protocols like to
|
||||
// share this interface?
|
||||
|
||||
/*
|
||||
Request functions-
|
||||
These functions set/get parameters on the outbound request and may only
|
||||
be set before Load() function gets called. Calling them after
|
||||
the Load() method will result in a NS_ERROR_ALREADY_CONNECTED
|
||||
*/
|
||||
NS_IMETHOD GetRequest(nsIHTTPRequest* *o_Request) const = 0;
|
||||
NS_IMETHOD SetRequest(nsIHTTPRequest* i_Request) = 0;
|
||||
|
||||
/*
|
||||
Response funtion. A call to this implicitly calls Load() on this
|
||||
protocol instance. Thats why it's not const.
|
||||
*/
|
||||
NS_IMETHOD GetResponse(nsIHTTPResponse* *o_Response) = 0;
|
||||
#endif // Past N2 things...
|
||||
|
||||
// All request functions before the Load gets called. These
|
||||
// should move to nsIHTTPRequest
|
||||
|
||||
/*
|
||||
I am not describing each since most are obvious and then
|
||||
it would be better to describe them in nsIHTTPRequest
|
||||
For most of these headers there is a default that gets
|
||||
set in a default HTTP request which can be modified from the
|
||||
nsIHTTPHandler.
|
||||
|
||||
This is definitely not the complete set. But nsIHTTPRequest will
|
||||
have it. TODO...
|
||||
*/
|
||||
NS_IMETHOD SetAccept(const char* i_AcceptHeader) = 0;
|
||||
//NS_IMETHOD SetAcceptType() = 0;
|
||||
NS_IMETHOD SetCookie(const char* i_Cookie) = 0;
|
||||
NS_IMETHOD SetUserAgent(const char* i_UserAgent) = 0;
|
||||
NS_IMETHOD SetHTTPVersion(HTTPVersion i_Version = HTTP_ONE_ONE) = 0;
|
||||
|
||||
// All response functions which if called, will call Load implicitly.
|
||||
// Should move these to nsIHTTPResponse.
|
||||
|
||||
NS_IMETHOD_(PRInt32) GetContentLength(void) const = 0;
|
||||
NS_IMETHOD GetContentType(const char* *o_Type) const = 0;
|
||||
//NS_IMETHOD_(PRTime) GetDate(void) const = 0;
|
||||
NS_IMETHOD_(PRInt32) GetResponseStatus(void) const = 0;
|
||||
NS_IMETHOD GetResponseString(const char* *o_String) const = 0;
|
||||
NS_IMETHOD GetServer(const char* *o_String) const = 0;
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {843D1020-D0DF-11d2-B013-006097BFC036}
|
||||
static const nsIID NS_IHTTPInstance_IID =
|
||||
{ 0x843d1020, 0xd0df, 0x11d2, { 0xb0, 0x13, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
|
||||
return NS_IHTTPInstance_IID;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//Possible errors
|
||||
//#define NS_ERROR_WHATEVER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 400);
|
||||
|
||||
#endif /* _nsIHTTPInstance_h_ */
|
||||
@@ -1,98 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIProtocolHandler_h_
|
||||
#define _nsIProtocolHandler_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsICoolURL.h"
|
||||
|
||||
/*
|
||||
The nsIProtocolHandler class is a common interface to all protocols
|
||||
being loaded dynamically. This base interface is required to be
|
||||
derived from, for all protocols that expect to be loaded dynamically.
|
||||
|
||||
Currently this just has functions to identify itself and return a
|
||||
ProtocolInstance for the specified URL. I will add more things after
|
||||
I find out more "common" elements for our two extreme cases HTTP and
|
||||
IMAP/SMTP
|
||||
|
||||
-Gagan Saksena
|
||||
|
||||
*/
|
||||
|
||||
class nsIProtocolHandler : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
GetDefaultPort returns the default port associated with this
|
||||
protocol.
|
||||
*/
|
||||
NS_IMETHOD_(PRInt32) GetDefaultPort(void) const = 0;
|
||||
|
||||
/*
|
||||
The GetProtocolInstance function. This function returns a per-URL
|
||||
instance of a dummy class nsIProtocolInstance which could be used
|
||||
for querying and setting per-URL properties of the connection. A
|
||||
protocol implementor may decide to reuse the same connection and
|
||||
hence supply the same protocol instance to handle the specified URL.
|
||||
*/
|
||||
NS_IMETHOD GetProtocolInstance(nsICoolURL* i_URL,
|
||||
nsIProtocolInstance* *o_Instance) = 0;
|
||||
|
||||
/*
|
||||
The GetScheme function uniquely identifies the scheme this handler
|
||||
is associated with.
|
||||
*/
|
||||
NS_IMETHOD GetScheme(const char* *o_Scheme) const = 0;
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {63E10A11-CD1F-11d2-B013-006097BFC036}
|
||||
static const nsIID NS_IProtocolHandler_IID =
|
||||
{ 0x63e10a11, 0xcd1f, 0x11d2, { 0xb0, 0x13, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
return NS_IProtocolHandler_IID;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Base Prog ID! Looks like a url but don't be fooled by its looks... it can kreate ya.
|
||||
#define NS_COMPONENT_NETSCAPE_NETWORK_PROTOCOLS "component://netscape/network/protocols&name="
|
||||
|
||||
#endif /* _nsIProtocolHandler_h_ */
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIProtocolInstance_h_
|
||||
#define _nsIProtocolInstance_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIInputStream;
|
||||
|
||||
/*
|
||||
The nsIProtocolInstance class is a common interface to all protocol
|
||||
functionality. This base interface will support at getting the input
|
||||
stream and the outputstream for the "connection"
|
||||
|
||||
There are still issues on what is the most common interface for the
|
||||
extreme cases of an interactive protocol like HTTP vs. events based
|
||||
one like SMTP/IMAP. This interface will probably go thru some
|
||||
redesigning.
|
||||
|
||||
-Gagan Saksena 03/15/99
|
||||
*/
|
||||
|
||||
class nsIProtocolInstance : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
The GetInputStream function. Note that this function is not a const
|
||||
and calling it may result in a state change for the protocol instance.
|
||||
Its upto the protocol to reflect an already open input stream through
|
||||
the return methods.
|
||||
*/
|
||||
NS_IMETHOD GetInputStream( nsIInputStream* *o_Stream) = 0;
|
||||
|
||||
/*
|
||||
The interrupt function for stopping an active instance.
|
||||
*/
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
|
||||
/*
|
||||
The load function that makes the actual attempt to starts the
|
||||
retrieval process. Depending upon the protocol's implementation
|
||||
this function may open the network connection.
|
||||
*/
|
||||
NS_IMETHOD Load(void) = 0;
|
||||
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {3594D180-CB85-11d2-A1BA-444553540000}
|
||||
static const nsIID NS_IProtocolInstance_IID =
|
||||
{ 0x3594d180, 0xcb85, 0x11d2, { 0xa1, 0xba, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
|
||||
return NS_IProtocolInstance_IID;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
/*
|
||||
Protocol's check for connection status. Once Load is called, this
|
||||
should return true. TODO THINK
|
||||
|
||||
NS_IMETHOD_(PRBool) IsConnected(void) = 0;
|
||||
*/
|
||||
|
||||
|
||||
};
|
||||
|
||||
//Possible errors
|
||||
#define NS_ERROR_ALREADY_CONNECTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 150);
|
||||
|
||||
#endif /* _nsIProtocolInstance_h_ */
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIProxy_h_
|
||||
#define _nsIProxy_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
/*
|
||||
The nsIProxy interface allows setting and getting of proxy host and port.
|
||||
This is for use by protocol handlers. If you are writing a protocol handler
|
||||
and would like to support proxy behaviour then derive from this as well as
|
||||
the nsIProtocolHandler class.
|
||||
|
||||
-Gagan Saksena 02/25/99
|
||||
*/
|
||||
|
||||
class nsIProxy : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
/*
|
||||
Get and Set the Proxy Host
|
||||
*/
|
||||
NS_IMETHOD GetProxyHost(const char* *o_ProxyHost) const = 0;
|
||||
NS_IMETHOD SetProxyHost(const char* i_ProxyHost) = 0;
|
||||
|
||||
/*
|
||||
Get and Set the Proxy Port
|
||||
-1 on Set call indicates switch to default port
|
||||
*/
|
||||
NS_IMETHOD_(PRInt32)
|
||||
GetProxyPort(void) const = 0;
|
||||
NS_IMETHOD SetProxyPort(PRInt32 i_ProxyPort) = 0;
|
||||
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {0492D011-CD2F-11d2-B013-006097BFC036}
|
||||
static const nsIID NS_IPROXY_IID=
|
||||
{ 0x492d011, 0xcd2f, 0x11d2, { 0xb0, 0x13, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
return NS_IPROXY_IID;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* _nsIProxy_h_ */
|
||||
@@ -1,145 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIURI_h_
|
||||
#define _nsIURI_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
/*
|
||||
The nsIURI class is an interface to the URI behaviour for parsing
|
||||
portions out of a URI. This follows Tim Berners-Lee's URI spec at-
|
||||
|
||||
http://www.w3.org/Addressing/URI/URI_Overview.html
|
||||
|
||||
For the purpose of this class, here is the most elaborate form of a URI
|
||||
and its corresponding parts-
|
||||
|
||||
ftp://username:password@hostname:portnumber/pathname
|
||||
\ / \ / \ / \ /\ /
|
||||
- --------------- ------ -------- -------
|
||||
| | | | |
|
||||
| | | | Path
|
||||
| | | Port
|
||||
| | Host
|
||||
| PreHost
|
||||
Scheme
|
||||
|
||||
Note that this class does not assume knowledge of search/query portions
|
||||
embedded within the path portion of the URI.
|
||||
|
||||
This class pretty much "final" and there shouldn't be anything added.
|
||||
If you do feel something belongs here, please do send me a mail. Thanks!
|
||||
|
||||
-Gagan Saksena 03/15/99
|
||||
*/
|
||||
|
||||
class nsIURI : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//Core parsing functions
|
||||
|
||||
/*
|
||||
The Scheme is the protocol that this URI refers to.
|
||||
*/
|
||||
NS_IMETHOD GetScheme(const char* *o_Scheme) const = 0;
|
||||
NS_IMETHOD SetScheme(const char* i_Scheme) = 0;
|
||||
|
||||
/*
|
||||
The PreHost portion includes elements like the optional
|
||||
username:password, or maybe other scheme specific items.
|
||||
*/
|
||||
NS_IMETHOD GetPreHost(const char* *o_PreHost) const = 0;
|
||||
NS_IMETHOD SetPreHost(const char* i_PreHost) = 0;
|
||||
|
||||
/*
|
||||
The Host is the internet domain name to which this URI refers.
|
||||
Note that it could be an IP address as well.
|
||||
*/
|
||||
NS_IMETHOD GetHost(const char* *o_Host) const = 0;
|
||||
NS_IMETHOD SetHost(const char* i_Host) = 0;
|
||||
|
||||
/*
|
||||
A return value of -1 indicates that no port value is set and the
|
||||
implementor of the specific scheme will use its default port.
|
||||
Similarly setting a value of -1 indicates that the default is to be used.
|
||||
Thus as an example-
|
||||
for HTTP, Port 80 is same as a return value of -1.
|
||||
However after setting a port (even if its default), the port number will
|
||||
appear in the ToString function.
|
||||
*/
|
||||
NS_IMETHOD_(PRInt32)
|
||||
GetPort(void) const = 0;
|
||||
NS_IMETHOD SetPort(PRInt32 i_Port) = 0;
|
||||
|
||||
/*
|
||||
Note that the path includes the leading '/' Thus if no path is
|
||||
available the GetPath will return a "/"
|
||||
For SetPath if none is provided, one would be prefixed to the path.
|
||||
*/
|
||||
NS_IMETHOD GetPath(const char* *o_Path) const = 0;
|
||||
NS_IMETHOD SetPath(const char* i_Path) = 0;
|
||||
|
||||
//Other utility functions
|
||||
/*
|
||||
Note that this comparison is only on char* level. Use
|
||||
the scheme specific URI to do a more thorough check. For example--
|
||||
in HTTP-
|
||||
http://foo.com:80 == http://foo.com
|
||||
but this function through nsIURI alone will not return equality
|
||||
for this case.
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) Equals(const nsIURI* i_URI) const = 0;
|
||||
|
||||
/*
|
||||
Writes a string representation of the URI.
|
||||
*/
|
||||
NS_IMETHOD ToString(const char* *o_URIString) const = 0;
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {EF4B5380-C07A-11d2-A1BA-00609794CF59}
|
||||
static const nsIID NS_IURI_IID =
|
||||
{ 0xef4b5380, 0xc07a, 0x11d2, { 0xa1, 0xba, 0x0, 0x60, 0x97, 0x94, 0xcf, 0x59 } };
|
||||
return NS_IURI_IID;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif /* _nsIURI_h_ */
|
||||
Reference in New Issue
Block a user