Source Code Cross Referenced for HttpRequestImpl.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » catalina » connector » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Rimfaxe Web Server » org.apache.catalina.connector.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpRequestImpl.java,v 1.13 2002/03/18 07:15:40 remm Exp $
003:         * $Revision: 1.13 $
004:         * $Date: 2002/03/18 07:15:40 $
005:         *
006:         * ====================================================================
007:         *
008:         * The Apache Software License, Version 1.1
009:         *
010:         * Copyright (c) 1999 The Apache Software Foundation.  All rights
011:         * reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions
015:         * are met:
016:         *
017:         * 1. Redistributions of source code must retain the above copyright
018:         *    notice, this list of conditions and the following disclaimer.
019:         *
020:         * 2. Redistributions in binary form must reproduce the above copyright
021:         *    notice, this list of conditions and the following disclaimer in
022:         *    the documentation and/or other materials provided with the
023:         *    distribution.
024:         *
025:         * 3. The end-user documentation included with the redistribution, if
026:         *    any, must include the following acknowlegement:
027:         *       "This product includes software developed by the
028:         *        Apache Software Foundation (http://www.apache.org/)."
029:         *    Alternately, this acknowlegement may appear in the software itself,
030:         *    if and wherever such third-party acknowlegements normally appear.
031:         *
032:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033:         *    Foundation" must not be used to endorse or promote products derived
034:         *    from this software without prior written permission. For written
035:         *    permission, please contact apache@apache.org.
036:         *
037:         * 5. Products derived from this software may not be called "Apache"
038:         *    nor may "Apache" appear in their names without prior written
039:         *    permission of the Apache Group.
040:         *
041:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         *
055:         * This software consists of voluntary contributions made by many
056:         * individuals on behalf of the Apache Software Foundation.  For more
057:         * information on the Apache Software Foundation, please see
058:         * <http://www.apache.org/>.
059:         *
060:         * [Additional notices, if required by prior licensing conditions]
061:         *
062:         */
063:
064:        package org.apache.catalina.connector.http;
065:
066:        import java.io.IOException;
067:        import java.net.InetAddress;
068:        import java.security.AccessController;
069:        import java.security.PrivilegedAction;
070:        import java.util.ArrayList;
071:        import java.util.Enumeration;
072:        import javax.servlet.ServletInputStream;
073:        import org.apache.catalina.connector.HttpRequestBase;
074:        import org.apache.catalina.util.Enumerator;
075:
076:        /**
077:         * Implementation of <b>HttpRequest</b> specific to the HTTP connector.
078:         *
079:         * @author Craig R. McClanahan
080:         * @author Remy Maucherat
081:         * @version $Revision: 1.13 $ $Date: 2002/03/18 07:15:40 $
082:         * @deprecated
083:         */
084:
085:        final class HttpRequestImpl extends HttpRequestBase {
086:
087:            // -------------------------------------------------------------- Constants
088:
089:            /**
090:             * Initial pool size.
091:             */
092:            protected static final int INITIAL_POOL_SIZE = 10;
093:
094:            /**
095:             * Pool size increment.
096:             */
097:            protected static final int POOL_SIZE_INCREMENT = 5;
098:
099:            // ----------------------------------------------------- Instance Variables
100:
101:            /**
102:             * The InetAddress of the remote client of ths request.
103:             */
104:            protected InetAddress inet = null;
105:
106:            /**
107:             * Descriptive information about this Request implementation.
108:             */
109:            protected static final String info = "org.apache.catalina.connector.http.HttpRequestImpl/1.0";
110:
111:            /**
112:             * Headers pool.
113:             */
114:            protected HttpHeader[] headerPool = new HttpHeader[INITIAL_POOL_SIZE];
115:
116:            /**
117:             * Position of the next available header in the pool.
118:             */
119:            protected int nextHeader = 0;
120:
121:            /**
122:             * Connection header.
123:             */
124:            protected HttpHeader connectionHeader = null;
125:
126:            /**
127:             * Transfer encoding header.
128:             */
129:            protected HttpHeader transferEncodingHeader = null;
130:
131:            // ------------------------------------------------------------- Properties
132:
133:            /**
134:             * [Package Private] Return the InetAddress of the remote client of
135:             * this request.
136:             */
137:            InetAddress getInet() {
138:
139:                return (inet);
140:
141:            }
142:
143:            /**
144:             * [Package Private] Set the InetAddress of the remote client of
145:             * this request.
146:             *
147:             * @param inet The new InetAddress
148:             */
149:            void setInet(InetAddress inet) {
150:
151:                this .inet = inet;
152:
153:            }
154:
155:            /**
156:             * Return descriptive information about this Request implementation and
157:             * the corresponding version number, in the format
158:             * <code>&lt;description&gt;/&lt;version&gt;</code>.
159:             */
160:            public String getInfo() {
161:
162:                return (info);
163:
164:            }
165:
166:            // --------------------------------------------------------- Public Methods
167:
168:            /**
169:             * Release all object references, and initialize instance variables, in
170:             * preparation for reuse of this object.
171:             */
172:            public void recycle() {
173:
174:                super .recycle();
175:                inet = null;
176:                nextHeader = 0;
177:                connectionHeader = null;
178:
179:            }
180:
181:            /**
182:             * Create and return a ServletInputStream to read the content
183:             * associated with this Request.  The default implementation creates an
184:             * instance of RequestStream associated with this request, but this can
185:             * be overridden if necessary.
186:             *
187:             * @exception IOException if an input/output error occurs
188:             */
189:            public ServletInputStream createInputStream() throws IOException {
190:
191:                return (new HttpRequestStream(this , (HttpResponseImpl) response));
192:
193:            }
194:
195:            /**
196:             * Allocate new header.
197:             *
198:             * @return an HttpHeader buffer allocated from the pool
199:             */
200:            HttpHeader allocateHeader() {
201:                if (nextHeader == headerPool.length) {
202:                    // Grow the pool
203:                    HttpHeader[] newHeaderPool = new HttpHeader[headerPool.length
204:                            + POOL_SIZE_INCREMENT];
205:                    for (int i = 0; i < nextHeader; i++) {
206:                        newHeaderPool[i] = headerPool[i];
207:                    }
208:                    headerPool = newHeaderPool;
209:                }
210:                if (headerPool[nextHeader] == null)
211:                    headerPool[nextHeader] = new HttpHeader();
212:                return headerPool[nextHeader];
213:            }
214:
215:            /**
216:             * Go to the next header.
217:             */
218:            void nextHeader() {
219:                nextHeader++;
220:            }
221:
222:            /**
223:             * Add a Header to the set of Headers associated with this Request.
224:             *
225:             * @param name The new header name
226:             * @param value The new header value
227:             * @deprecated Don't use
228:             */
229:            public void addHeader(String name, String value) {
230:
231:                if (nextHeader == headerPool.length) {
232:                    // Grow the pool
233:                    HttpHeader[] newHeaderPool = new HttpHeader[headerPool.length
234:                            + POOL_SIZE_INCREMENT];
235:                    for (int i = 0; i < nextHeader; i++) {
236:                        newHeaderPool[i] = headerPool[i];
237:                    }
238:                    headerPool = newHeaderPool;
239:                }
240:                headerPool[nextHeader++] = new HttpHeader(name, value);
241:
242:            }
243:
244:            /**
245:             * Clear the collection of Headers associated with this Request.
246:             */
247:            public void clearHeaders() {
248:
249:                nextHeader = 0;
250:
251:            }
252:
253:            /**
254:             * Return the first value of the specified header, if any; otherwise,
255:             * return <code>null</code>
256:             *
257:             * @param header Header we want to retrieve
258:             */
259:            public HttpHeader getHeader(HttpHeader header) {
260:
261:                for (int i = 0; i < nextHeader; i++) {
262:                    if (headerPool[i].equals(header))
263:                        return headerPool[i];
264:                }
265:                return null;
266:
267:            }
268:
269:            /**
270:             * Return the first value of the specified header, if any; otherwise,
271:             * return <code>null</code>
272:             *
273:             * @param headerName Name of the requested header
274:             */
275:            public HttpHeader getHeader(char[] headerName) {
276:
277:                for (int i = 0; i < nextHeader; i++) {
278:                    if (headerPool[i].equals(headerName))
279:                        return headerPool[i];
280:                }
281:                return null;
282:
283:            }
284:
285:            /**
286:             * Perform whatever actions are required to flush and close the input
287:             * stream or reader, in a single operation.
288:             *
289:             * @exception IOException if an input/output error occurs
290:             */
291:            public void finishRequest() throws IOException {
292:
293:                // If neither a reader or an is have been opened, do it to consume
294:                // request bytes, if any
295:                if ((reader == null) && (stream == null)
296:                        && (getContentLength() != 0) && (getProtocol() != null)
297:                        && (getProtocol().equals("HTTP/1.1")))
298:                    getInputStream();
299:
300:                super .finishRequest();
301:
302:            }
303:
304:            // ------------------------------------------------- ServletRequest Methods
305:
306:            /**
307:             * Return the Internet Protocol (IP) address of the client that sent
308:             * this request.
309:             */
310:            public String getRemoteAddr() {
311:
312:                return (inet.getHostAddress());
313:
314:            }
315:
316:            /**
317:             * Return the fully qualified name of the client that sent this request,
318:             * or the IP address of the client if the name cannot be determined.
319:             */
320:            public String getRemoteHost() {
321:
322:                if (connector.getEnableLookups())
323:                    return (inet.getHostName());
324:                else
325:                    return (getRemoteAddr());
326:
327:            }
328:
329:            // --------------------------------------------- HttpServletRequest Methods
330:
331:            /**
332:             * Return the first value of the specified header, if any; otherwise,
333:             * return <code>null</code>
334:             *
335:             * @param name Name of the requested header
336:             */
337:            public String getHeader(String name) {
338:
339:                name = name.toLowerCase();
340:                for (int i = 0; i < nextHeader; i++) {
341:                    if (headerPool[i].equals(name))
342:                        return new String(headerPool[i].value, 0,
343:                                headerPool[i].valueEnd);
344:                }
345:                return null;
346:
347:            }
348:
349:            /**
350:             * Return all of the values of the specified header, if any; otherwise,
351:             * return an empty enumeration.
352:             *
353:             * @param name Name of the requested header
354:             */
355:            public Enumeration getHeaders(String name) {
356:
357:                name = name.toLowerCase();
358:                ArrayList tempArrayList = new ArrayList();
359:                for (int i = 0; i < nextHeader; i++) {
360:                    if (headerPool[i].equals(name))
361:                        tempArrayList.add(new String(headerPool[i].value, 0,
362:                                headerPool[i].valueEnd));
363:                }
364:                return (Enumeration) new Enumerator(tempArrayList);
365:
366:            }
367:
368:            /**
369:             * Return the names of all headers received with this request.
370:             */
371:            public Enumeration getHeaderNames() {
372:                ArrayList tempArrayList = new ArrayList();
373:                for (int i = 0; i < nextHeader; i++) {
374:                    tempArrayList.add(new String(headerPool[i].name, 0,
375:                            headerPool[i].nameEnd));
376:                }
377:                return (Enumeration) new Enumerator(tempArrayList);
378:
379:            }
380:
381:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.