зеркало из https://github.com/mozilla/gecko-dev.git
Brought in the original work.
This commit is contained in:
Родитель
d3fd9d4555
Коммит
1dc46c4054
|
@ -24,11 +24,12 @@ EXPORTS = \
|
|||
nsIConnectionGroup.h \
|
||||
nsIFileTransportService.h \
|
||||
nsINetService.h \
|
||||
nsIProtocolConnection.h \
|
||||
nsIProtocolInstance.h \
|
||||
nsIProtocolHandler.h \
|
||||
nsIStreamListener.h \
|
||||
nsITransport.h \
|
||||
nsIUrl.h \
|
||||
nsIURL.h \
|
||||
nsIURI.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _nsIHeader_h_
|
||||
#define _nsIHeader_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
/*
|
||||
nsIHeader. A class to encapsulate and share the header reading and
|
||||
writing on requests/responses of several protocols.
|
||||
|
||||
I am not convinced the GetHeaderMultiple is the right way to
|
||||
do multiple values, but give me a better way... TODO think.
|
||||
|
||||
- Gagan Saksena 03/08/99
|
||||
*/
|
||||
|
||||
class nsIHeader : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
SetHeader- set a particular header. The implementation is protocol
|
||||
specific. For e.g. HTTP will put a colon and space to separate
|
||||
the header with the value and then trail it will an newline.
|
||||
So SetHeader for HTTP with say ("Accept", "text/html") will
|
||||
result in a string "Accept: text/html\n" being added to the header
|
||||
set.
|
||||
*/
|
||||
NS_IMETHOD SetHeader(const char* i_Header, const char* i_Value) = 0;
|
||||
|
||||
/*
|
||||
Get the first occurence of the header and its corresponding value.
|
||||
Note that if you expect the possibility of multiple values, you
|
||||
should use GetHeaderMultiple() version.
|
||||
*/
|
||||
NS_IMETHOD GetHeader(const char* i_Header, const char* *o_Value) const = 0;
|
||||
|
||||
/*
|
||||
This version returns an array of values associated with this
|
||||
header. TODO think of a better way to do this...
|
||||
*/
|
||||
NS_IMETHOD GetHeaderMultiple(
|
||||
const char* i_Header,
|
||||
const char** *o_ValueArray,
|
||||
int o_Count) const = 0;
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {4CD2C720-D5CF-11d2-B013-006097BFC036}
|
||||
static const nsIID NS_IHEADER_IID =
|
||||
{ 0x4cd2c720, 0xd5cf, 0x11d2, { 0xb0, 0x13, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
|
||||
return NS_IHEADER_IID;
|
||||
}
|
||||
}
|
||||
#endif // _nsIHeader_h_
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIUrl;
|
||||
class nsIProtocolConnection;
|
||||
class nsIURL;
|
||||
class nsIProtocolInstance;
|
||||
class nsIConnectionGroup;
|
||||
class nsIProtocolHandler;
|
||||
|
||||
|
@ -47,18 +47,18 @@ class nsINetService : public nsISupports
|
|||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INETSERVICE_IID);
|
||||
|
||||
NS_IMETHOD GetProtocolHandler(nsIUrl* url, nsIProtocolHandler* *result) = 0;
|
||||
NS_IMETHOD GetProtocolHandler(nsIURL* url, nsIProtocolHandler* *result) = 0;
|
||||
|
||||
NS_IMETHOD NewConnectionGroup(nsIConnectionGroup* *result) = 0;
|
||||
|
||||
NS_IMETHOD NewURL(nsIUrl* *result,
|
||||
NS_IMETHOD NewURL(nsIURL* *result,
|
||||
const char* aSpec,
|
||||
const nsIUrl* aBaseURL,
|
||||
const nsIURL* aBaseURL,
|
||||
nsISupports* aContainer) = 0;
|
||||
|
||||
NS_IMETHOD Open(nsIUrl* url, nsISupports* eventSink,
|
||||
NS_IMETHOD Open(nsIURL* url, nsISupports* eventSink,
|
||||
nsIConnectionGroup* group,
|
||||
nsIProtocolConnection* *result) = 0;
|
||||
nsIProtocolInstance* *result) = 0;
|
||||
|
||||
/**
|
||||
* @return NS_OK if there are active connections
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
|
@ -16,36 +16,73 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIProtocolHandler_h___
|
||||
#define nsIProtocolHandler_h___
|
||||
#ifndef _nsIProtocolHandler_h_
|
||||
#define _nsIProtocolHandler_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
class nsIConnectionGroup;
|
||||
class nsIConnectionGroup; // This should really be nsIURLGroup. TODO change
|
||||
|
||||
#define NS_IPROTOCOLHANDLER_IID \
|
||||
{ /* 5da8b1b0-ea35-11d2-931b-00104ba0fd40 */ \
|
||||
0x5da8b1b0, \
|
||||
0xea35, \
|
||||
0x11d2, \
|
||||
{0x93, 0x1b, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
|
||||
}
|
||||
/*
|
||||
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:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPROTOCOLHANDLER_IID);
|
||||
|
||||
NS_IMETHOD GetScheme(const char* *o_Scheme) = 0;
|
||||
/*
|
||||
GetDefaultPort returns the default port associated with this
|
||||
protocol.
|
||||
*/
|
||||
NS_IMETHOD_(PRInt32) GetDefaultPort(void) const = 0;
|
||||
|
||||
NS_IMETHOD GetDefaultPort(PRInt32 *result) = 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(nsIURL* i_URL,
|
||||
nsIProtocolInstance* *o_Instance,
|
||||
nsIConnectionGroup* i_Group = 0) = 0;
|
||||
|
||||
/*
|
||||
The GetScheme function uniquely identifies the scheme this handler
|
||||
is associated with.
|
||||
*/
|
||||
NS_IMETHOD GetScheme(const char* *o_Scheme) const = 0;
|
||||
|
||||
/*
|
||||
The Open function directly assumes that the information in the
|
||||
URL and the default header information with this handler is
|
||||
sufficient to make a connection and process the request. So
|
||||
This is the same as getting the protocol instance and right away
|
||||
calling Load on it.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
|
||||
NS_IMETHOD Open(nsIUrl* url, nsISupports* eventSink,
|
||||
nsIConnectionGroup* group,
|
||||
nsIProtocolConnection* *result) = 0;
|
||||
};
|
||||
|
||||
#define NS_NETWORK_PROTOCOL_PROGID "component://netscape/network/protocol?name="
|
||||
#define NS_NETWORK_PROTOCOL_PROGID_PREFIX NS_NETWORK_PROTOCOL_PROGID "?name="
|
||||
// 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 /* nsIIProtocolHandler_h___ */
|
||||
#endif /* _nsIProtocolHandler_h_ */
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _nsIProtocolInstance_h_
|
||||
#define _nsIProtocolInstance_h_
|
||||
|
||||
#include "nsICancelable.h"
|
||||
class nsIInputStream;
|
||||
class nsIOutputStream;
|
||||
|
||||
/*
|
||||
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 nsICancelable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
The BLOCKING 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 BLOCKING GetOutputStream 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 closed
|
||||
connection through the return methods.
|
||||
*/
|
||||
NS_IMETHOD GetOutputStream(nsIOutputStream* *o_Stream) = 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 Connect(nsISupports* i_EventSink) = 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_ */
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _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_ */
|
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _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. If *o_URIString is null,
|
||||
a new one will be created. Free it with delete[]
|
||||
*/
|
||||
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_ */
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
|
@ -16,112 +16,116 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIUrl_h___
|
||||
#define nsIUrl_h___
|
||||
#ifndef _nsIURL_h_
|
||||
#define _nsIURL_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
/*
|
||||
The nsIURL 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
|
||||
|
||||
#undef GetPort // Windows (sigh)
|
||||
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.
|
||||
|
||||
#define NS_IURL_IID \
|
||||
{ /* 82c1b000-ea35-11d2-931b-00104ba0fd40 */ \
|
||||
0x82c1b000, \
|
||||
0xea35, \
|
||||
0x11d2, \
|
||||
{0x93, 0x1b, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
|
||||
}
|
||||
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
|
||||
|
||||
/**
|
||||
* 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!
|
||||
*/
|
||||
class nsIUrl : public nsISupports
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIProtocolInstance.h"
|
||||
|
||||
class nsIURL : public nsIURI
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IURL_IID);
|
||||
|
||||
// Core parsing functions
|
||||
|
||||
/**
|
||||
* The Scheme is the protocol that this URI refers to.
|
||||
*/
|
||||
NS_IMETHOD GetScheme(const char* *result) = 0;
|
||||
NS_IMETHOD SetScheme(const char* scheme) = 0;
|
||||
|
||||
/**
|
||||
* The PreHost portion includes elements like the optional
|
||||
* username:password, or maybe other scheme specific items.
|
||||
*/
|
||||
NS_IMETHOD GetPreHost(const char* *result) = 0;
|
||||
NS_IMETHOD SetPreHost(const char* 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* *result) = 0;
|
||||
NS_IMETHOD SetHost(const char* 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.
|
||||
|
||||
/*
|
||||
Used for testing purposes. if you need a string representation for
|
||||
your work, use ToString().
|
||||
*/
|
||||
NS_IMETHOD GetPort(PRInt32 *result) = 0;
|
||||
NS_IMETHOD SetPort(PRInt32 port) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD DebugString(const char* *o_URLString) const=0;
|
||||
#endif //DEBUG
|
||||
|
||||
/**
|
||||
* 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* *result) = 0;
|
||||
NS_IMETHOD SetPath(const char* path) = 0;
|
||||
//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;
|
||||
|
||||
// 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.
|
||||
* @return NS_OK if equal
|
||||
* @return NS_COMFALSE if not equal
|
||||
*/
|
||||
NS_IMETHOD Equals(const nsIUrl* other) = 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.
|
||||
|
||||
/**
|
||||
* Writes a string representation of the URI.
|
||||
* Free string with delete[].
|
||||
*/
|
||||
NS_IMETHOD ToNewCString(const char* *uriString) = 0;
|
||||
TODO - return status?
|
||||
*/
|
||||
NS_IMETHOD GetDocument(const char* *o_Data) = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
MakeAbsoluteFrom function takes a new string that is a relative url,
|
||||
and converts this object to represent the final form. As an example
|
||||
if this is "http://foo/bar" and we call MakeAbsoluteFrom("/baz")
|
||||
then this will change to "http://foo/baz" There is a whole series
|
||||
of possibilities here. Check this URL for more details (TODO -Gagan)
|
||||
*/
|
||||
NS_IMETHOD MakeAbsoluteFrom(const char* i_NewURL) = 0;
|
||||
|
||||
/*
|
||||
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;
|
||||
|
||||
|
||||
|
||||
static const nsIID& GetIID() {
|
||||
// {6DA32F00-BD64-11d2-B00F-006097BFC036}
|
||||
static const nsIID NS_IURL_IID =
|
||||
{ 0x6da32f00, 0xbd64, 0x11d2, { 0xb0, 0xf, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
return NS_IURL_IID;
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* nsIIUrl_h___ */
|
||||
// Should change to NS_METHOD CreateURL(nsIURL* *o_URL, const char* i_URL)
|
||||
// and be placed where?
|
||||
extern NS_NET
|
||||
nsIURL* CreateURL(const char* i_URL);
|
||||
|
||||
|
||||
#endif /* _nsIURL_h_ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче