2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is the Gopher protocol code.
19 * The Initial Developer of the Original Code is
21 * Portions created by the Initial Developer are Copyright (C) 2000
22 * the Initial Developer. All Rights Reserved.
25 * Bradley Baetz <bbaetz@student.usyd.edu.au>
26 * Darin Fisher <darin@meer.net>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
42 #include "nsGopherChannel.h"
43 #include "nsGopherHandler.h"
45 #include "nsIComponentManager.h"
46 #include "nsIServiceManager.h"
47 #include "nsIStandardURL.h"
48 #include "nsStandardURL.h"
50 //-----------------------------------------------------------------------------
52 NS_IMPL_THREADSAFE_ISUPPORTS2(nsGopherHandler
,
53 nsIProxiedProtocolHandler
,
56 //-----------------------------------------------------------------------------
59 nsGopherHandler::GetScheme(nsACString
&result
)
61 result
.AssignLiteral("gopher");
66 nsGopherHandler::GetDefaultPort(PRInt32
*result
)
68 *result
= GOPHER_PORT
;
73 nsGopherHandler::GetProtocolFlags(PRUint32
*result
)
75 *result
= URI_NORELATIVE
| ALLOWS_PROXY
| ALLOWS_PROXY_HTTP
|
76 URI_LOADABLE_BY_ANYONE
;
81 nsGopherHandler::NewURI(const nsACString
&spec
, const char *originCharset
,
82 nsIURI
*baseURI
, nsIURI
**result
)
84 nsStandardURL
*url
= new nsStandardURL();
86 return NS_ERROR_OUT_OF_MEMORY
;
89 nsresult rv
= url
->Init(nsIStandardURL::URLTYPE_STANDARD
, GOPHER_PORT
,
90 spec
, originCharset
, baseURI
);
96 *result
= url
; // no QI needed
101 nsGopherHandler::NewProxiedChannel(nsIURI
*uri
, nsIProxyInfo
*proxyInfo
,
104 NS_ENSURE_ARG_POINTER(uri
);
105 nsGopherChannel
*chan
= new nsGopherChannel(uri
, proxyInfo
);
107 return NS_ERROR_OUT_OF_MEMORY
;
110 nsresult rv
= chan
->Init();
121 nsGopherHandler::NewChannel(nsIURI
*uri
, nsIChannel
**result
)
123 return NewProxiedChannel(uri
, nsnull
, result
);
127 nsGopherHandler::AllowPort(PRInt32 port
, const char *scheme
, PRBool
*result
)
129 *result
= (port
== GOPHER_PORT
);