nsIProtocolHandler.idl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsISupports.idl"
  38. interface nsIURI;
  39. interface nsIChannel;
  40. /**
  41. * nsIProtocolHandler
  42. *
  43. * @status FROZEN
  44. */
  45. [scriptable, uuid(15fd6940-8ea7-11d3-93ad-00104ba0fd40)]
  46. interface nsIProtocolHandler : nsISupports
  47. {
  48. /**
  49. * The scheme of this protocol (e.g., "file").
  50. */
  51. readonly attribute ACString scheme;
  52. /**
  53. * The default port is the port that this protocol normally uses.
  54. * If a port does not make sense for the protocol (e.g., "about:")
  55. * then -1 will be returned.
  56. */
  57. readonly attribute long defaultPort;
  58. /**
  59. * Returns the protocol specific flags (see flag definitions below).
  60. */
  61. readonly attribute unsigned long protocolFlags;
  62. /**
  63. * Makes a URI object that is suitable for loading by this protocol,
  64. * where the URI string is given as an UTF-8 string. The caller may
  65. * provide the charset from which the URI string originated, so that
  66. * the URI string can be translated back to that charset (if necessary)
  67. * before communicating with, for example, the origin server of the URI
  68. * string. (Many servers do not support UTF-8 IRIs at the present time,
  69. * so we must be careful about tracking the native charset of the origin
  70. * server.)
  71. *
  72. * @param aSpec - the URI string in UTF-8 encoding. depending
  73. * on the protocol implementation, unicode character
  74. * sequences may or may not be %xx escaped.
  75. * @param aOriginCharset - the charset of the document from which this URI
  76. * string originated. this corresponds to the
  77. * charset that should be used when communicating
  78. * this URI to an origin server, for example. if
  79. * null, then UTF-8 encoding is assumed (i.e.,
  80. * no charset transformation from aSpec).
  81. * @param aBaseURI - if null, aSpec must specify an absolute URI.
  82. * otherwise, aSpec may be resolved relative
  83. * to aBaseURI, depending on the protocol.
  84. * If the protocol has no concept of relative
  85. * URI aBaseURI will simply be ignored.
  86. */
  87. nsIURI newURI(in AUTF8String aSpec,
  88. in string aOriginCharset,
  89. in nsIURI aBaseURI);
  90. /**
  91. * Constructs a new channel from the given URI for this protocol handler.
  92. */
  93. nsIChannel newChannel(in nsIURI aURI);
  94. /**
  95. * Allows a protocol to override blacklisted ports.
  96. *
  97. * This method will be called when there is an attempt to connect to a port
  98. * that is blacklisted. For example, for most protocols, port 25 (Simple Mail
  99. * Transfer) is banned. When a URI containing this "known-to-do-bad-things"
  100. * port number is encountered, this function will be called to ask if the
  101. * protocol handler wants to override the ban.
  102. */
  103. boolean allowPort(in long port, in string scheme);
  104. /**************************************************************************
  105. * Constants for the protocol flags (the first is the default mask, the
  106. * others are deviations):
  107. *
  108. * NOTE: Implementation must ignore any flags they do not understand.
  109. */
  110. /**
  111. * standard full URI with authority component and concept of relative
  112. * URIs (http, ftp, ...)
  113. */
  114. const unsigned long URI_STD = 0;
  115. /**
  116. * no concept of relative URIs (about, javascript, finger, ...)
  117. */
  118. const unsigned long URI_NORELATIVE = (1<<0);
  119. /**
  120. * no authority component (file, ...)
  121. */
  122. const unsigned long URI_NOAUTH = (1<<1);
  123. /**
  124. * This protocol handler can be proxied via a proxy (socks or http)
  125. * (e.g., irc, smtp, http, etc.). If the protocol supports transparent
  126. * proxying, the handler should implement nsIProxiedProtocolHandler.
  127. *
  128. * If it supports only HTTP proxying, then it need not support
  129. * nsIProxiedProtocolHandler, but should instead set the ALLOWS_PROXY_HTTP
  130. * flag (see below).
  131. *
  132. * @see nsIProxiedProtocolHandler
  133. */
  134. const unsigned long ALLOWS_PROXY = (1<<2);
  135. /**
  136. * This protocol handler can be proxied using a http proxy (e.g., http,
  137. * ftp, etc.). nsIIOService::newChannelFromURI will feed URIs from this
  138. * protocol handler to the HTTP protocol handler instead. This flag is
  139. * ignored if ALLOWS_PROXY is not set.
  140. */
  141. const unsigned long ALLOWS_PROXY_HTTP = (1<<3);
  142. };
  143. %{C++
  144. /**
  145. * Protocol handlers are registered with XPCOM under the following CONTRACTID prefix:
  146. */
  147. #define NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "@mozilla.org/network/protocol;1?name="
  148. /**
  149. * For example, "@mozilla.org/network/protocol;1?name=http"
  150. */
  151. %}