nsIChannel.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/mozilla/netwerk/base/public/nsIChannel.idl
  3. */
  4. #ifndef __gen_nsIChannel_h__
  5. #define __gen_nsIChannel_h__
  6. #ifndef __gen_nsIRequest_h__
  7. #include "nsIRequest.h"
  8. #endif
  9. /* For IDL files that don't want to include root IDL files. */
  10. #ifndef NS_NO_VTABLE
  11. #define NS_NO_VTABLE
  12. #endif
  13. class nsIURI; /* forward declaration */
  14. class nsIInterfaceRequestor; /* forward declaration */
  15. class nsIInputStream; /* forward declaration */
  16. class nsIStreamListener; /* forward declaration */
  17. /* starting interface: nsIChannel */
  18. #define NS_ICHANNEL_IID_STR "c63a055a-a676-4e71-bf3c-6cfa11082018"
  19. #define NS_ICHANNEL_IID \
  20. {0xc63a055a, 0xa676, 0x4e71, \
  21. { 0xbf, 0x3c, 0x6c, 0xfa, 0x11, 0x08, 0x20, 0x18 }}
  22. /**
  23. * The nsIChannel interface allows clients to construct "GET" requests for
  24. * specific protocols, and manage them in a uniform way. Once a channel is
  25. * created (via nsIIOService::newChannel), parameters for that request may
  26. * be set by using the channel attributes, or by QI'ing to a subclass of
  27. * nsIChannel for protocol-specific parameters. Then, the URI can be fetched
  28. * by calling nsIChannel::open or nsIChannel::asyncOpen.
  29. *
  30. * After a request has been completed, the channel is still valid for accessing
  31. * protocol-specific results. For example, QI'ing to nsIHttpChannel allows
  32. * response headers to be retrieved for the corresponding http transaction.
  33. *
  34. * @status FROZEN
  35. */
  36. class NS_NO_VTABLE nsIChannel : public nsIRequest {
  37. public:
  38. NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICHANNEL_IID)
  39. /**
  40. * The original URI used to construct the channel. This is used in the case
  41. * of a redirect or URI "resolution" (e.g. resolving a resource: URI to a
  42. * file: URI) so that the original pre-redirect URI can still be obtained.
  43. *
  44. * NOTE: this is distinctly different from the http Referer (referring URI),
  45. * which is typically the page that contained the original URI (accessible
  46. * from nsIHttpChannel).
  47. */
  48. /* attribute nsIURI originalURI; */
  49. NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI) = 0;
  50. NS_IMETHOD SetOriginalURI(nsIURI * aOriginalURI) = 0;
  51. /**
  52. * The URI corresponding to the channel. Its value is immutable.
  53. */
  54. /* readonly attribute nsIURI URI; */
  55. NS_IMETHOD GetURI(nsIURI * *aURI) = 0;
  56. /**
  57. * The owner, corresponding to the entity that is responsible for this
  58. * channel. Used by the security manager to grant or deny privileges to
  59. * mobile code loaded from this channel.
  60. *
  61. * NOTE: this is a strong reference to the owner, so if the owner is also
  62. * holding a strong reference to the channel, care must be taken to
  63. * explicitly drop its reference to the channel.
  64. */
  65. /* attribute nsISupports owner; */
  66. NS_IMETHOD GetOwner(nsISupports * *aOwner) = 0;
  67. NS_IMETHOD SetOwner(nsISupports * aOwner) = 0;
  68. /**
  69. * The notification callbacks for the channel. This is set by clients, who
  70. * wish to provide a means to receive progress, status and protocol-specific
  71. * notifications. If this value is NULL, the channel implementation may use
  72. * the notification callbacks from its load group. The channel may also
  73. * query the notification callbacks from its load group if its notification
  74. * callbacks do not supply the requested interface.
  75. *
  76. * Interfaces commonly requested include: nsIProgressEventSink, nsIPrompt,
  77. * and nsIAuthPrompt.
  78. *
  79. * When the channel is done, it must not continue holding references to
  80. * this object.
  81. *
  82. * NOTE: A channel implementation should take care when "caching" an
  83. * interface pointer queried from its notification callbacks. If the
  84. * notification callbacks are changed, then a cached interface pointer may
  85. * become invalid and may therefore need to be re-queried.
  86. */
  87. /* attribute nsIInterfaceRequestor notificationCallbacks; */
  88. NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) = 0;
  89. NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) = 0;
  90. /**
  91. * Transport-level security information (if any) corresponding to the channel.
  92. */
  93. /* readonly attribute nsISupports securityInfo; */
  94. NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) = 0;
  95. /**
  96. * The MIME type of the channel's content if available.
  97. *
  98. * NOTE: the content type can often be wrongly specified (e.g., wrong file
  99. * extension, wrong MIME type, wrong document type stored on a server, etc.),
  100. * and the caller most likely wants to verify with the actual data.
  101. *
  102. * Setting contentType before the channel has been opened provides a hint
  103. * to the channel as to what the MIME type is. The channel may ignore this
  104. * hint in deciding on the actual MIME type that it will report.
  105. *
  106. * Setting contentType after onStartRequest has been fired or after open()
  107. * is called will override the type determined by the channel.
  108. *
  109. * Setting contentType between the time that asyncOpen() is called and the
  110. * time when onStartRequest is fired has undefined behavior at this time.
  111. *
  112. * The value of the contentType attribute is a lowercase string. A value
  113. * assigned to this attribute will be parsed and normalized as follows:
  114. * 1- any parameters (delimited with a ';') will be stripped.
  115. * 2- if a charset parameter is given, then its value will replace the
  116. * the contentCharset attribute of the channel.
  117. * 3- the stripped contentType will be lowercased.
  118. * Any implementation of nsIChannel must follow these rules.
  119. */
  120. /* attribute ACString contentType; */
  121. NS_IMETHOD GetContentType(nsACString & aContentType) = 0;
  122. NS_IMETHOD SetContentType(const nsACString & aContentType) = 0;
  123. /**
  124. * The character set of the channel's content if available and if applicable.
  125. * This attribute only applies to textual data.
  126. *
  127. * The value of the contentCharset attribute is a mixedcase string.
  128. */
  129. /* attribute ACString contentCharset; */
  130. NS_IMETHOD GetContentCharset(nsACString & aContentCharset) = 0;
  131. NS_IMETHOD SetContentCharset(const nsACString & aContentCharset) = 0;
  132. /**
  133. * The length of the data associated with the channel if available. A value
  134. * of -1 indicates that the content length is unknown.
  135. *
  136. * Callers should prefer getting the "content-length" property
  137. * as 64-bit value by QIing the channel to nsIPropertyBag2,
  138. * if that interface is exposed by the channel.
  139. */
  140. /* attribute long contentLength; */
  141. NS_IMETHOD GetContentLength(PRInt32 *aContentLength) = 0;
  142. NS_IMETHOD SetContentLength(PRInt32 aContentLength) = 0;
  143. /**
  144. * Synchronously open the channel.
  145. *
  146. * @return blocking input stream to the channel's data.
  147. *
  148. * NOTE: nsIChannel implementations are not required to implement this
  149. * method. Moreover, since this method may block the calling thread, it
  150. * should not be called on a thread that processes UI events.
  151. */
  152. /* nsIInputStream open (); */
  153. NS_IMETHOD Open(nsIInputStream **_retval) = 0;
  154. /**
  155. * Asynchronously open this channel. Data is fed to the specified stream
  156. * listener as it becomes available. The stream listener's methods are
  157. * called on the thread that calls asyncOpen and are not called until
  158. * after asyncOpen returns.
  159. *
  160. * @param aListener the nsIStreamListener implementation
  161. * @param aContext an opaque parameter forwarded to aListener's methods
  162. */
  163. /* void asyncOpen (in nsIStreamListener aListener, in nsISupports aContext); */
  164. NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) = 0;
  165. /**************************************************************************
  166. * Channel specific load flags:
  167. *
  168. * Bits 21-31 are reserved for future use by this interface or one of its
  169. * derivatives (e.g., see nsICachingChannel).
  170. */
  171. /**
  172. * Set (e.g., by the docshell) to indicate whether or not the channel
  173. * corresponds to a document URI.
  174. */
  175. enum { LOAD_DOCUMENT_URI = 65536U };
  176. /**
  177. * If the end consumer for this load has been retargeted after discovering
  178. * it's content, this flag will be set:
  179. */
  180. enum { LOAD_RETARGETED_DOCUMENT_URI = 131072U };
  181. /**
  182. * This flag is set to indicate that onStopRequest may be followed by
  183. * another onStartRequest/onStopRequest pair. This flag is, for example,
  184. * used by the multipart/replace stream converter.
  185. */
  186. enum { LOAD_REPLACE = 262144U };
  187. /**
  188. * Set (e.g., by the docshell) to indicate whether or not the channel
  189. * corresponds to an initial document URI load (e.g., link click).
  190. */
  191. enum { LOAD_INITIAL_DOCUMENT_URI = 524288U };
  192. /**
  193. * Set (e.g., by the URILoader) to indicate whether or not the end consumer
  194. * for this load has been determined.
  195. */
  196. enum { LOAD_TARGETED = 1048576U };
  197. };
  198. /* Use this macro when declaring classes that implement this interface. */
  199. #define NS_DECL_NSICHANNEL \
  200. NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI); \
  201. NS_IMETHOD SetOriginalURI(nsIURI * aOriginalURI); \
  202. NS_IMETHOD GetURI(nsIURI * *aURI); \
  203. NS_IMETHOD GetOwner(nsISupports * *aOwner); \
  204. NS_IMETHOD SetOwner(nsISupports * aOwner); \
  205. NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks); \
  206. NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks); \
  207. NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo); \
  208. NS_IMETHOD GetContentType(nsACString & aContentType); \
  209. NS_IMETHOD SetContentType(const nsACString & aContentType); \
  210. NS_IMETHOD GetContentCharset(nsACString & aContentCharset); \
  211. NS_IMETHOD SetContentCharset(const nsACString & aContentCharset); \
  212. NS_IMETHOD GetContentLength(PRInt32 *aContentLength); \
  213. NS_IMETHOD SetContentLength(PRInt32 aContentLength); \
  214. NS_IMETHOD Open(nsIInputStream **_retval); \
  215. NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext); \
  216. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  217. #define NS_FORWARD_NSICHANNEL(_to) \
  218. NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI) { return _to GetOriginalURI(aOriginalURI); } \
  219. NS_IMETHOD SetOriginalURI(nsIURI * aOriginalURI) { return _to SetOriginalURI(aOriginalURI); } \
  220. NS_IMETHOD GetURI(nsIURI * *aURI) { return _to GetURI(aURI); } \
  221. NS_IMETHOD GetOwner(nsISupports * *aOwner) { return _to GetOwner(aOwner); } \
  222. NS_IMETHOD SetOwner(nsISupports * aOwner) { return _to SetOwner(aOwner); } \
  223. NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { return _to GetNotificationCallbacks(aNotificationCallbacks); } \
  224. NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return _to SetNotificationCallbacks(aNotificationCallbacks); } \
  225. NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { return _to GetSecurityInfo(aSecurityInfo); } \
  226. NS_IMETHOD GetContentType(nsACString & aContentType) { return _to GetContentType(aContentType); } \
  227. NS_IMETHOD SetContentType(const nsACString & aContentType) { return _to SetContentType(aContentType); } \
  228. NS_IMETHOD GetContentCharset(nsACString & aContentCharset) { return _to GetContentCharset(aContentCharset); } \
  229. NS_IMETHOD SetContentCharset(const nsACString & aContentCharset) { return _to SetContentCharset(aContentCharset); } \
  230. NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return _to GetContentLength(aContentLength); } \
  231. NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return _to SetContentLength(aContentLength); } \
  232. NS_IMETHOD Open(nsIInputStream **_retval) { return _to Open(_retval); } \
  233. NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) { return _to AsyncOpen(aListener, aContext); } \
  234. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  235. #define NS_FORWARD_SAFE_NSICHANNEL(_to) \
  236. NS_IMETHOD GetOriginalURI(nsIURI * *aOriginalURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOriginalURI(aOriginalURI); } \
  237. NS_IMETHOD SetOriginalURI(nsIURI * aOriginalURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOriginalURI(aOriginalURI); } \
  238. NS_IMETHOD GetURI(nsIURI * *aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetURI(aURI); } \
  239. NS_IMETHOD GetOwner(nsISupports * *aOwner) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOwner(aOwner); } \
  240. NS_IMETHOD SetOwner(nsISupports * aOwner) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetOwner(aOwner); } \
  241. NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetNotificationCallbacks(aNotificationCallbacks); } \
  242. NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetNotificationCallbacks(aNotificationCallbacks); } \
  243. NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSecurityInfo(aSecurityInfo); } \
  244. NS_IMETHOD GetContentType(nsACString & aContentType) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentType(aContentType); } \
  245. NS_IMETHOD SetContentType(const nsACString & aContentType) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentType(aContentType); } \
  246. NS_IMETHOD GetContentCharset(nsACString & aContentCharset) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentCharset(aContentCharset); } \
  247. NS_IMETHOD SetContentCharset(const nsACString & aContentCharset) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentCharset(aContentCharset); } \
  248. NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetContentLength(aContentLength); } \
  249. NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetContentLength(aContentLength); } \
  250. NS_IMETHOD Open(nsIInputStream **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Open(_retval); } \
  251. NS_IMETHOD AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext) { return !_to ? NS_ERROR_NULL_POINTER : _to->AsyncOpen(aListener, aContext); } \
  252. #if 0
  253. /* Use the code below as a template for the implementation class for this interface. */
  254. /* Header file */
  255. class nsChannel : public nsIChannel
  256. {
  257. public:
  258. NS_DECL_ISUPPORTS
  259. NS_DECL_NSICHANNEL
  260. nsChannel();
  261. private:
  262. ~nsChannel();
  263. protected:
  264. /* additional members */
  265. };
  266. /* Implementation file */
  267. NS_IMPL_ISUPPORTS1(nsChannel, nsIChannel)
  268. nsChannel::nsChannel()
  269. {
  270. /* member initializers and constructor code */
  271. }
  272. nsChannel::~nsChannel()
  273. {
  274. /* destructor code */
  275. }
  276. /* attribute nsIURI originalURI; */
  277. NS_IMETHODIMP nsChannel::GetOriginalURI(nsIURI * *aOriginalURI)
  278. {
  279. return NS_ERROR_NOT_IMPLEMENTED;
  280. }
  281. NS_IMETHODIMP nsChannel::SetOriginalURI(nsIURI * aOriginalURI)
  282. {
  283. return NS_ERROR_NOT_IMPLEMENTED;
  284. }
  285. /* readonly attribute nsIURI URI; */
  286. NS_IMETHODIMP nsChannel::GetURI(nsIURI * *aURI)
  287. {
  288. return NS_ERROR_NOT_IMPLEMENTED;
  289. }
  290. /* attribute nsISupports owner; */
  291. NS_IMETHODIMP nsChannel::GetOwner(nsISupports * *aOwner)
  292. {
  293. return NS_ERROR_NOT_IMPLEMENTED;
  294. }
  295. NS_IMETHODIMP nsChannel::SetOwner(nsISupports * aOwner)
  296. {
  297. return NS_ERROR_NOT_IMPLEMENTED;
  298. }
  299. /* attribute nsIInterfaceRequestor notificationCallbacks; */
  300. NS_IMETHODIMP nsChannel::GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks)
  301. {
  302. return NS_ERROR_NOT_IMPLEMENTED;
  303. }
  304. NS_IMETHODIMP nsChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks)
  305. {
  306. return NS_ERROR_NOT_IMPLEMENTED;
  307. }
  308. /* readonly attribute nsISupports securityInfo; */
  309. NS_IMETHODIMP nsChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
  310. {
  311. return NS_ERROR_NOT_IMPLEMENTED;
  312. }
  313. /* attribute ACString contentType; */
  314. NS_IMETHODIMP nsChannel::GetContentType(nsACString & aContentType)
  315. {
  316. return NS_ERROR_NOT_IMPLEMENTED;
  317. }
  318. NS_IMETHODIMP nsChannel::SetContentType(const nsACString & aContentType)
  319. {
  320. return NS_ERROR_NOT_IMPLEMENTED;
  321. }
  322. /* attribute ACString contentCharset; */
  323. NS_IMETHODIMP nsChannel::GetContentCharset(nsACString & aContentCharset)
  324. {
  325. return NS_ERROR_NOT_IMPLEMENTED;
  326. }
  327. NS_IMETHODIMP nsChannel::SetContentCharset(const nsACString & aContentCharset)
  328. {
  329. return NS_ERROR_NOT_IMPLEMENTED;
  330. }
  331. /* attribute long contentLength; */
  332. NS_IMETHODIMP nsChannel::GetContentLength(PRInt32 *aContentLength)
  333. {
  334. return NS_ERROR_NOT_IMPLEMENTED;
  335. }
  336. NS_IMETHODIMP nsChannel::SetContentLength(PRInt32 aContentLength)
  337. {
  338. return NS_ERROR_NOT_IMPLEMENTED;
  339. }
  340. /* nsIInputStream open (); */
  341. NS_IMETHODIMP nsChannel::Open(nsIInputStream **_retval)
  342. {
  343. return NS_ERROR_NOT_IMPLEMENTED;
  344. }
  345. /* void asyncOpen (in nsIStreamListener aListener, in nsISupports aContext); */
  346. NS_IMETHODIMP nsChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
  347. {
  348. return NS_ERROR_NOT_IMPLEMENTED;
  349. }
  350. /* End of implementation class template. */
  351. #endif
  352. #endif /* __gen_nsIChannel_h__ */