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) 2001
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Akkana Peck <akkana@netscape.com> (original author)
24 * Darin Fisher <darin@meer.net>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 #include "nsIRequest.idl"
41
42 interface nsIURI;
43 interface nsIChannel;
44 interface nsIRequestObserver;
45
46 /**
47 * nsIURIChecker
48 *
49 * The URI checker is a component that can be used to verify the existance
50 * of a resource at the location specified by a given URI. It will use
51 * protocol specific methods to verify the URI (e.g., use of HEAD request
52 * for HTTP URIs).
53 */
54 [scriptable, uuid(4660c1a1-be2d-4c78-9baf-c22984176c28)]
55 interface nsIURIChecker : nsIRequest
56 {
57 /**
58 * Initializes the URI checker. After this method is called, it is valid
59 * to further configure the URI checker by calling its nsIRequest methods.
60 * This method creates the channel that will be used to verify the URI.
61 * In the case of the HTTP protocol, only a HEAD request will be issued.
62 *
63 * @param aURI
64 * The URI to be checked.
65 */
66 void init(in nsIURI aURI);
67
68 /**
69 * Returns the base channel that will be used to verify the URI.
70 */
71 readonly attribute nsIChannel baseChannel;
72
73 /**
74 * Begin asynchronous checking URI for validity. Notification will be
75 * asynchronous through the nsIRequestObserver callback interface. When
76 * OnStartRequest is fired, the baseChannel attribute will have been
77 * updated to reflect the final channel used (corresponding to any redirects
78 * that may have been followed).
79 *
80 * Our interpretations of the nsIRequestObserver status codes:
81 * NS_BINDING_SUCCEEDED: link is valid
82 * NS_BINDING_FAILED: link is invalid (gave an error)
83 * NS_BINDING_ABORTED: timed out, or cancelled
84 *
85 * @param aObserver
86 * The object to notify when the link is verified. We will
87 * call aObserver.OnStartRequest followed immediately by
88 * aObserver.OnStopRequest. It is recommended that the caller use
89 * OnStopRequest to act on the link's status. The underlying request
90 * will not be cancelled until after OnStopRequest has been called.
91 * @param aContext
92 * A closure that will be passed back to the nsIRequestObserver
93 * methods.
94 */
95 void asyncCheck(in nsIRequestObserver aObserver, in nsISupports aContext);
96 };