Source Code Cross Referenced for Tomcat3Request.java in  » Sevlet-Container » tomcat-connectors » org » apache » coyote » tomcat3 » 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 » Sevlet Container » tomcat connectors » org.apache.coyote.tomcat3 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 1999-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:
017:        package org.apache.coyote.tomcat3;
018:
019:        import java.io.IOException;
020:
021:        import org.apache.coyote.ActionCode;
022:        import org.apache.tomcat.util.buf.ByteChunk;
023:        import org.apache.tomcat.util.buf.MessageBytes;
024:
025:        /** The Request to connect with Coyote.
026:         *  This class handles the I/O requirements and transferring the request
027:         *  line and Mime headers between Coyote and Tomcat.
028:         * 
029:         *  @author Bill Barker
030:         *  @author Costin Manolache
031:         */
032:        public class Tomcat3Request extends org.apache.tomcat.core.Request {
033:
034:            org.apache.coyote.Request coyoteRequest = null;
035:
036:            // For SSL attributes we need to call an ActionHook to get
037:            // info from the protocol handler.
038:            //    SSLSupport sslSupport=null;
039:
040:            ByteChunk readChunk = new ByteChunk(8096);
041:            int pos = -1;
042:            int end = -1;
043:            byte[] readBuffer = null;
044:
045:            public Tomcat3Request() {
046:                super ();
047:                remoteAddrMB.recycle();
048:                remoteHostMB.recycle();
049:            }
050:
051:            public void recycle() {
052:                super .recycle();
053:                if (coyoteRequest != null)
054:                    coyoteRequest.recycle();
055:
056:                remoteAddrMB.recycle();
057:                remoteHostMB.recycle();
058:                readChunk.recycle();
059:
060:                readBuffer = null;
061:                pos = -1;
062:                end = -1;
063:            }
064:
065:            public org.apache.coyote.Request getCoyoteRequest() {
066:                return coyoteRequest;
067:            }
068:
069:            /** Attach the Coyote Request to this Request.
070:             *  This is currently set pre-request to allow copying the request
071:             *  attributes to the Tomcat attributes.
072:             */
073:            public void setCoyoteRequest(org.apache.coyote.Request cReq) {
074:                coyoteRequest = cReq;
075:
076:                // The CoyoteRequest/Tomcat3Request are bound togheter, they
077:                // don't change. That means we can use the same field ( which
078:                // doesn't change as well.
079:                schemeMB = coyoteRequest.scheme();
080:                methodMB = coyoteRequest.method();
081:                uriMB = coyoteRequest.requestURI();
082:                queryMB = coyoteRequest.query();
083:                protoMB = coyoteRequest.protocol();
084:
085:                headers = coyoteRequest.getMimeHeaders();
086:                scookies.setHeaders(headers);
087:                params.setHeaders(headers);
088:                params.setQuery(queryMB);
089:
090:                remoteAddrMB = coyoteRequest.remoteAddr();
091:                remoteHostMB = coyoteRequest.remoteHost();
092:                serverNameMB = coyoteRequest.serverName();
093:
094:            }
095:
096:            /** Read a single character from the request body.
097:             */
098:            public int doRead() throws IOException {
099:                if (available == 0)
100:                    return -1;
101:                // #3745
102:                // if available == -1: unknown length, we'll read until end of stream.
103:                if (available != -1)
104:                    available--;
105:                if (pos >= end) {
106:                    if (readBytes() < 0)
107:                        return -1;
108:                }
109:                return readBuffer[pos++] & 0xFF;
110:            }
111:
112:            /** Read a chunk from the request body.
113:             */
114:            public int doRead(byte[] b, int off, int len) throws IOException {
115:                if (available == 0)
116:                    return -1;
117:                // if available == -1: unknown length, we'll read until end of stream.
118:                if (pos >= end) {
119:                    if (readBytes() <= 0)
120:                        return -1;
121:                }
122:                int rd = -1;
123:                if ((end - pos) > len) {
124:                    rd = len;
125:                } else {
126:                    rd = end - pos;
127:                }
128:
129:                System.arraycopy(readBuffer, pos, b, off, rd);
130:                pos += rd;
131:                if (available != -1)
132:                    available -= rd;
133:
134:                return rd;
135:            }
136:
137:            /**
138:             * Read bytes to the read chunk buffer.
139:             */
140:            protected int readBytes() throws IOException {
141:
142:                int result = coyoteRequest.doRead(readChunk);
143:                if (result > 0) {
144:                    readBuffer = readChunk.getBytes();
145:                    end = readChunk.getEnd();
146:                    pos = readChunk.getStart();
147:                } else if (result < 0) {
148:                    throw new IOException("Read bytes failed " + result);
149:                }
150:                return result;
151:
152:            }
153:
154:            // -------------------- override special methods
155:
156:            public MessageBytes remoteAddr() {
157:                if (remoteAddrMB.isNull()) {
158:                    coyoteRequest.action(
159:                            ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE,
160:                            coyoteRequest);
161:                }
162:                return remoteAddrMB;
163:            }
164:
165:            public MessageBytes remoteHost() {
166:                if (remoteHostMB.isNull()) {
167:                    coyoteRequest.action(ActionCode.ACTION_REQ_HOST_ATTRIBUTE,
168:                            coyoteRequest);
169:                }
170:                return remoteHostMB;
171:            }
172:
173:            public String getLocalHost() {
174:                return localHost;
175:            }
176:
177:            public MessageBytes serverName() {
178:                // That's set by protocol in advance, it's needed for mapping anyway,
179:                // no need to do lazy eval.
180:                return coyoteRequest.serverName();
181:            }
182:
183:            public int getServerPort() {
184:                return coyoteRequest.getServerPort();
185:            }
186:
187:            public void setServerPort(int i) {
188:                coyoteRequest.setServerPort(i);
189:            }
190:
191:            public void setRemoteUser(String s) {
192:                super .setRemoteUser(s);
193:                coyoteRequest.getRemoteUser().setString(s);
194:            }
195:
196:            public String getRemoteUser() {
197:                String s = coyoteRequest.getRemoteUser().toString();
198:                if (s == null)
199:                    s = super .getRemoteUser();
200:                return s;
201:            }
202:
203:            public String getAuthType() {
204:                return coyoteRequest.getAuthType().toString();
205:            }
206:
207:            public void setAuthType(String s) {
208:                coyoteRequest.getAuthType().setString(s);
209:            }
210:
211:            public String getJvmRoute() {
212:                return coyoteRequest.instanceId().toString();
213:            }
214:
215:            public void setJvmRoute(String s) {
216:                coyoteRequest.instanceId().setString(s);
217:            }
218:
219:            public boolean isSecure() {
220:                return "https".equalsIgnoreCase(coyoteRequest.scheme()
221:                        .toString());
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.