Source Code Cross Referenced for Request.java in  » Web-Server » Jigsaw » org » w3c » www » protocol » 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 » Jigsaw » org.w3c.www.protocol.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Request.java
002:        // $Id: Request.java,v 1.13 2003/04/01 16:45:49 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.www.protocol.http;
007:
008:        import java.io.IOException;
009:        import java.io.InputStream;
010:        import java.io.OutputStream;
011:
012:        import org.w3c.www.http.HttpMessage;
013:        import org.w3c.www.http.HttpRequestMessage;
014:
015:        /**
016:         * The client side idea of a request.
017:         * Requests are created only by the HttpManager, by cloning its template 
018:         * request that defines the default (application wide) request settings.
019:         */
020:
021:        public class Request extends HttpRequestMessage {
022:            /**
023:             * The manager that created this request.
024:             */
025:            protected HttpManager manager = null;
026:            /**
027:             * Are we allowed to interact with the user ?
028:             */
029:            protected boolean allowuserinteraction = false;
030:            /**
031:             * The request output stream, to PUT or POST data.
032:             */
033:            protected InputStream output = null;
034:            /**
035:             * The observer for the request, if any.
036:             */
037:            protected RequestObserver observer = null;
038:            /**
039:             * Can we pipeline that request, if appropriate support is detected ?
040:             */
041:            protected boolean pipeline = true;
042:            /**
043:             * Has this request been interrupted ?
044:             */
045:            protected boolean interrupted = false;
046:            /**
047:             * The server <em>currently</em> running the request, if any.
048:             */
049:            protected HttpServer server = null;
050:
051:            /**
052:             * Mark that request has being run by given server.
053:             * @param server The server in charge for that request.
054:             */
055:
056:            protected synchronized void setServer(HttpServer server) {
057:                this .server = server;
058:            }
059:
060:            /**
061:             * Mark that request as no longer attached to a server object.
062:             */
063:
064:            protected synchronized void unsetServer() {
065:                this .server = null;
066:            }
067:
068:            /**
069:             * Enable/disable pipelining for that request.
070:             * By default, this HTTP implementation tries it's best to use pipelining,
071:             * if you take manual control over it, you're responsible for damages.
072:             * @param onoff The pipelining toggle.
073:             */
074:
075:            public void setPipeline(boolean onoff) {
076:                this .pipeline = onoff;
077:            }
078:
079:            /**
080:             * End of header emiting, continue by sending optional output stream.
081:             * @param out The output stream to write to.
082:             */
083:
084:            protected void endEmit(OutputStream out, int what)
085:                    throws IOException {
086:                if ((what & EMIT_BODY) != EMIT_BODY)
087:                    return;
088:                if (output != null) {
089:                    byte buf[] = new byte[1024];
090:                    int cnt = 0;
091:                    int total = 0;
092:                    while ((cnt = output.read(buf)) >= 0) {
093:                        total += cnt;
094:                        out.write(buf, 0, cnt);
095:                    }
096:                    //	    output.close();
097:                }
098:                return;
099:            }
100:
101:            /**
102:             * Are we allowed to do some user interaction to run this request.
103:             * @return A boolean, <strong>true</strong> if user interaction is allowed
104:             * <strong>false</strong> otherwise.
105:             */
106:
107:            public boolean getAllowUserInteraction() {
108:                return allowuserinteraction;
109:            }
110:
111:            /**
112:             * Decide wether we are allowed to interact wit hthe user.
113:             * @param onoff A boolean, <strong>true</strong> if interaction is allowed.
114:             */
115:
116:            public void setAllowUserInteraction(boolean onoff) {
117:                allowuserinteraction = onoff;
118:            }
119:
120:            /**
121:             * Interrupt that request processing.
122:             * Do whatever it takes to interrupt that request processing, as soon
123:             * as possible.
124:             */
125:
126:            public synchronized void interruptRequest() {
127:                interrupted = true;
128:                if (server != null)
129:                    server.interruptRequest(this );
130:            }
131:
132:            /**
133:             * Has this request been interrupted ?
134:             * @return A boolean.
135:             */
136:
137:            public boolean isInterrupted() {
138:                return interrupted;
139:            }
140:
141:            /**
142:             * Get this request's manager.
143:             * @return The instance of the manager taking care of this request.
144:             */
145:
146:            public HttpManager getManager() {
147:                return manager;
148:            }
149:
150:            /**
151:             * Set this request output stream.
152:             * As a side effect, setting the body of the request will disable
153:             * pipelining. If you know what you're doing, you can turn it on again by 
154:             * using the <code>setPipeline</code> method.
155:             * @param in The data to send to the server.
156:             */
157:
158:            public void setOutputStream(InputStream in) {
159:                this .output = in;
160:                this .pipeline = false;
161:            }
162:
163:            /**
164:             * Does this request has an associated input stream ?
165:             * @return A boolean <strong>true</strong> of it has.
166:             */
167:
168:            public boolean hasOutputStream() {
169:                return output != null;
170:            }
171:
172:            /**
173:             * Get the input stream to read that request body.
174:             * <strong>Warning</strong> it is up to the caller to make sure to:
175:             * <ul>
176:             * <li>Reset the content length if any bytes is read out of the stream 
177:             * before the request is sent.
178:             * <li>Reset the entire stream is the filter acting upon it just want to 
179:             * peek it (without consuming it).
180:             * </ul>
181:             * @return An InputStream instance, or <strong>null</strong> if the request
182:             * has no body.
183:             */
184:
185:            public InputStream getOutputStream() {
186:                return output;
187:            }
188:
189:            /**
190:             * Create a Reply instance matching this request.
191:             */
192:
193:            public Reply makeReply(int status) {
194:                return new Reply(major, minor, status);
195:            }
196:
197:            /**
198:             * Set the observer for this request.
199:             * @param observer The observer.
200:             */
201:
202:            public void setObserver(RequestObserver observer) {
203:                this .observer = observer;
204:            }
205:
206:            /**
207:             * Get the observer for this request.
208:             * @return An instance of RequestObserver, or <strong>null</strong> 
209:             * if undefined.
210:             */
211:
212:            public RequestObserver getObserver() {
213:                return observer;
214:            }
215:
216:            protected Request(HttpManager manager) {
217:                super();
218:                this.manager = manager;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.