1 | | /* | | 1 | | /* |
2 | | * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java,v 1.4 2001/07/22 20 :25: 07 pier Exp $ | | 2 | | * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http10/HttpRequestImpl.java,v 1.5 2002/03/18 07:15:40 remm Exp $ |
3 | | * $Revision: 1.4 $ | | 3 | | * $Revision: 1.5 $ |
4 | | * $Date: 2001/07/22 20 :25: 07 $ | | 4 | | * $Date: 2002/03/18 07:15:40 $ |
5 | | * | | 5 | | * |
6 | | * ==================================================================== | | 6 | | * ==================================================================== |
7 | | * | | 7 | | * |
8 | | * The Apache Software License, Version 1.1 | | 8 | | * The Apache Software License, Version 1.1 |
9 | | * | | 9 | | * |
10 | | * Copyright (c) 1999 The Apache Software Foundation. All rights | | 10 | | * Copyright (c) 1999 The Apache Software Foundation. All rights |
11 | | * reserved. | | 11 | | * reserved. |
12 | | * | | 12 | | * |
13 | | * Redistribution and use in source and binary forms, with or without | | 13 | | * Redistribution and use in source and binary forms, with or without |
14 | | * modification, are permitted provided that the following conditions | | 14 | | * modification, are permitted provided that the following conditions |
15 | | * are met: | | 15 | | * are met: |
16 | | * | | 16 | | * |
17 | | * 1. Redistributions of source code must retain the above copyright | | 17 | | * 1. Redistributions of source code must retain the above copyright |
18 | | * notice, this list of conditions and the following disclaimer. | | 18 | | * notice, this list of conditions and the following disclaimer. |
19 | | * | | 19 | | * |
20 | | * 2. Redistributions in binary form must reproduce the above copyright | | 20 | | * 2. Redistributions in binary form must reproduce the above copyright |
21 | | * notice, this list of conditions and the following disclaimer in | | 21 | | * notice, this list of conditions and the following disclaimer in |
22 | | * the documentation and/or other materials provided with the | | 22 | | * the documentation and/or other materials provided with the |
23 | | * distribution. | | 23 | | * distribution. |
24 | | * | | 24 | | * |
25 | | * 3. The end-user documentation included with the redistribution, if | | 25 | | * 3. The end-user documentation included with the redistribution, if |
26 | | * any, must include the following acknowlegement: | | 26 | | * any, must include the following acknowlegement: |
27 | | * "This product includes software developed by the | | 27 | | * "This product includes software developed by the |
28 | | * Apache Software Foundation (http://www.apache.org/)." | | 28 | | * Apache Software Foundation (http://www.apache.org/)." |
29 | | * Alternately, this acknowlegement may appear in the software itself, | | 29 | | * Alternately, this acknowlegement may appear in the software itself, |
30 | | * if and wherever such third-party acknowlegements normally appear. | | 30 | | * if and wherever such third-party acknowlegements normally appear. |
31 | | * | | 31 | | * |
32 | | * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | | 32 | | * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software |
33 | | * Foundation" must not be used to endorse or promote products derived | | 33 | | * Foundation" must not be used to endorse or promote products derived |
34 | | * from this software without prior written permission. For written | | 34 | | * from this software without prior written permission. For written |
35 | | * permission, please contact apache@apache.org. | | 35 | | * permission, please contact apache@apache.org. |
36 | | * | | 36 | | * |
37 | | * 5. Products derived from this software may not be called "Apache" | | 37 | | * 5. Products derived from this software may not be called "Apache" |
38 | | * nor may "Apache" appear in their names without prior written | | 38 | | * nor may "Apache" appear in their names without prior written |
39 | | * permission of the Apache Group. | | 39 | | * permission of the Apache Group. |
40 | | * | | 40 | | * |
41 | | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | | 41 | | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
42 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 42 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
43 | | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 43 | | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
44 | | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | | 44 | | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR |
45 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 45 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
46 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | | 46 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
47 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | | 47 | | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
48 | | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | | 48 | | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
49 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 49 | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
50 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | | 50 | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
51 | | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 51 | | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
52 | | * SUCH DAMAGE. | | 52 | | * SUCH DAMAGE. |
53 | | * ==================================================================== | | 53 | | * ==================================================================== |
54 | | * | | 54 | | * |
55 | | * This software consists of voluntary contributions made by many | | 55 | | * This software consists of voluntary contributions made by many |
56 | | * individuals on behalf of the Apache Software Foundation. For more | | 56 | | * individuals on behalf of the Apache Software Foundation. For more |
57 | | * information on the Apache Software Foundation, please see | | 57 | | * information on the Apache Software Foundation, please see |
58 | | * <http://www.apache.org/>. | | 58 | | * <http://www.apache.org/>. |
59 | | * | | 59 | | * |
60 | | * [Additional notices, if required by prior licensing conditions] | | 60 | | * [Additional notices, if required by prior licensing conditions] |
61 | | * | | 61 | | * |
62 | | */ | | 62 | | */ |
63 | | | | 63 | | |
64 | | | | 64 | | |
65 | | package org.apache.catalina.connector.http10; | | 65 | | package org.apache.catalina.connector.http10; |
66 | | | | 66 | | |
67 | | | | 67 | | |
68 | | import java.net.InetAddress; | | 68 | | import java.net.InetAddress; |
69 | | import org.apache.catalina.connector.HttpRequestBase; | | 69 | | import org.apache.catalina.connector.HttpRequestBase; |
70 | | | | 70 | | |
71 | | | | 71 | | |
72 | | /** | | 72 | | /** |
73 | | * Implementation of <b>HttpRequest</b> specific to the HTTP connector. | | 73 | | * Implementation of <b>HttpRequest</b> specific to the HTTP connector. |
74 | | * | | 74 | | * |
75 | | * @author Craig R. McClanahan | | 75 | | * @author Craig R. McClanahan |
76 | | * @version $Revision: 1.4 $ $Date: 2001/07/22 20 :25: 07 $ | | 76 | | * @version $Revision: 1.5 $ $Date: 2002/03/18 07:15:40 $ |
| | | | 77 | | * @deprecated |
77 | | */ | | 78 | | */ |
78 | | | | 79 | | |
79 | | final class HttpRequestImpl | | 80 | | final class HttpRequestImpl |
80 | | extends HttpRequestBase { | | 81 | | extends HttpRequestBase { |
81 | | | | 82 | | |
82 | | | | 83 | | |
83 | | // ----------------------------------------------------- Instance Variables | | 84 | | // ----------------------------------------------------- Instance Variables |
84 | | | | 85 | | |
85 | | | | 86 | | |
86 | | /** | | 87 | | /** |
87 | | * The InetAddress of the remote client of ths request. | | 88 | | * The InetAddress of the remote client of ths request. |
88 | | */ | | 89 | | */ |
89 | | protected InetAddress inet = null; | | 90 | | protected InetAddress inet = null; |
90 | | | | 91 | | |
91 | | | | 92 | | |
92 | | /** | | 93 | | /** |
93 | | * Descriptive information about this Request implementation. | | 94 | | * Descriptive information about this Request implementation. |
94 | | */ | | 95 | | */ |
95 | | protected static final String info = | | 96 | | protected static final String info = |
96 | | "org.apache.catalina.connector.http10.HttpRequestImpl/1.0"; | | 97 | | "org.apache.catalina.connector.http10.HttpRequestImpl/1.0"; |
97 | | | | 98 | | |
98 | | | | 99 | | |
99 | | // ------------------------------------------------------------- Properties | | 100 | | // ------------------------------------------------------------- Properties |
100 | | | | 101 | | |
101 | | | | 102 | | |
102 | | /** | | 103 | | /** |
103 | | * [Package Private] Return the InetAddress of the remote client of | | 104 | | * [Package Private] Return the InetAddress of the remote client of |
104 | | * this request. | | 105 | | * this request. |
105 | | */ | | 106 | | */ |
106 | | InetAddress getInet() { | | 107 | | InetAddress getInet() { |
107 | | | | 108 | | |
108 | | return (inet); | | 109 | | return (inet); |
109 | | | | 110 | | |
110 | | } | | 111 | | } |
111 | | | | 112 | | |
112 | | | | 113 | | |
113 | | /** | | 114 | | /** |
114 | | * [Package Private] Set the InetAddress of the remote client of | | 115 | | * [Package Private] Set the InetAddress of the remote client of |
115 | | * this request. | | 116 | | * this request. |
116 | | * | | 117 | | * |
117 | | * @param inet The new InetAddress | | 118 | | * @param inet The new InetAddress |
118 | | */ | | 119 | | */ |
119 | | void setInet(InetAddress inet) { | | 120 | | void setInet(InetAddress inet) { |
120 | | | | 121 | | |
121 | | this.inet = inet; | | 122 | | this.inet = inet; |
122 | | | | 123 | | |
123 | | } | | 124 | | } |
124 | | | | 125 | | |
125 | | | | 126 | | |
126 | | /** | | 127 | | /** |
127 | | * Return descriptive information about this Request implementation and | | 128 | | * Return descriptive information about this Request implementation and |
128 | | * the corresponding version number, in the format | | 129 | | * the corresponding version number, in the format |
129 | | * <code><description>/<version></code>. | | 130 | | * <code><description>/<version></code>. |
130 | | */ | | 131 | | */ |
131 | | public String getInfo() { | | 132 | | public String getInfo() { |
132 | | | | 133 | | |
133 | | return (info); | | 134 | | return (info); |
134 | | | | 135 | | |
135 | | } | | 136 | | } |
136 | | | | 137 | | |
137 | | | | 138 | | |
138 | | // --------------------------------------------------------- Public Methods | | 139 | | // --------------------------------------------------------- Public Methods |
139 | | | | 140 | | |
140 | | | | 141 | | |
141 | | /** | | 142 | | /** |
142 | | * Release all object references, and initialize instance variables, in | | 143 | | * Release all object references, and initialize instance variables, in |
143 | | * preparation for reuse of this object. | | 144 | | * preparation for reuse of this object. |
144 | | */ | | 145 | | */ |
145 | | public void recycle() { | | 146 | | public void recycle() { |
146 | | | | 147 | | |
147 | | super.recycle(); | | 148 | | super.recycle(); |
148 | | inet = null; | | 149 | | inet = null; |
149 | | | | 150 | | |
150 | | } | | 151 | | } |
151 | | | | 152 | | |
152 | | | | 153 | | |
153 | | // ------------------------------------------------- ServletRequest Methods | | 154 | | // ------------------------------------------------- ServletRequest Methods |
154 | | | | 155 | | |
155 | | | | 156 | | |
156 | | /** | | 157 | | /** |
157 | | * Return the Internet Protocol (IP) address of the client that sent | | 158 | | * Return the Internet Protocol (IP) address of the client that sent |
158 | | * this request. | | 159 | | * this request. |
159 | | */ | | 160 | | */ |
160 | | public String getRemoteAddr() { | | 161 | | public String getRemoteAddr() { |
161 | | | | 162 | | |
162 | | return (inet.getHostAddress()); | | 163 | | return (inet.getHostAddress()); |
163 | | | | 164 | | |
164 | | } | | 165 | | } |
165 | | | | 166 | | |
166 | | | | 167 | | |
167 | | /** | | 168 | | /** |
168 | | * Return the fully qualified name of the client that sent this request, | | 169 | | * Return the fully qualified name of the client that sent this request, |
169 | | * or the IP address of the client if the name cannot be determined. | | 170 | | * or the IP address of the client if the name cannot be determined. |
170 | | */ | | 171 | | */ |
171 | | public String getRemoteHost() { | | 172 | | public String getRemoteHost() { |
172 | | | | 173 | | |
173 | | if (connector.getEnableLookups()) | | 174 | | if (connector.getEnableLookups()) |
174 | | return (inet.getHostName()); | | 175 | | return (inet.getHostName()); |
175 | | else | | 176 | | else |
176 | | return (getRemoteAddr()); | | 177 | | return (getRemoteAddr()); |
177 | | | | 178 | | |
178 | | } | | 179 | | } |
179 | | | | 180 | | |
180 | | | | 181 | | |
181 | | // --------------------------------------------- HttpServletRequest Methods | | 182 | | // --------------------------------------------- HttpServletRequest Methods |
182 | | | | 183 | | |
183 | | | | 184 | | |
184 | | } | | 185 | | } |