Source Code Cross Referenced for Request.java in  » Net » SkunkDAV » HTTPClient » 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 » Net » SkunkDAV » HTTPClient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)Request.java					0.3-2E 16/06/2000
003:         *
004:         *  This file is part of the HTTPClient package
005:         *  Copyright (C) 1996-2000  Ronald Tschalär
006:         *
007:         *  This library is free software; you can redistribute it and/or
008:         *  modify it under the terms of the GNU Lesser General Public
009:         *  License as published by the Free Software Foundation; either
010:         *  version 2 of the License, or (at your option) any later version.
011:         *
012:         *  This library is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *  Lesser General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU Lesser General Public
018:         *  License along with this library; if not, write to the Free
019:         *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
020:         *  MA 02111-1307, USA
021:         *
022:         *  For questions, suggestions, bug-reports, enhancement-requests etc.
023:         *  I may be contacted at:
024:         *
025:         *  ronald@innovation.ch
026:         *
027:         */
028:
029:        package HTTPClient;
030:
031:        /**
032:         * This class represents an http request. It's used by classes which
033:         * implement the HTTPClientModule interface.
034:         *
035:         * @version	0.3-2E  16/06/2000
036:         * @author	Ronald Tschalär
037:         */
038:
039:        public final class Request implements  RoRequest {
040:            /** null headers */
041:            private static final NVPair[] empty = new NVPair[0];
042:
043:            /** the current HTTPConnection */
044:            private HTTPConnection connection;
045:
046:            /** the request method to be used (e.g. GET, POST, etc) */
047:            private String method;
048:
049:            /** the request-uri */
050:            private String req_uri;
051:
052:            /** the headers to be used */
053:            private NVPair[] headers;
054:
055:            /** the entity (if any) */
056:            private byte[] data;
057:
058:            /** or an output stream on which the entity will be written */
059:            private HttpOutputStream stream;
060:
061:            /** are modules allowed to popup windows or otherwise prompt user? */
062:            private boolean allow_ui;
063:
064:            /** number of millisecs to wait for an error from the server before sending
065:            the entity (used when retrying requests) */
066:            long delay_entity = 0;
067:
068:            /** number of retries so far */
069:            int num_retries = 0;
070:
071:            /** disable pipelining of following request */
072:            boolean dont_pipeline = false;
073:
074:            /** was this request aborted by the user? */
075:            boolean aborted = false;
076:
077:            /** is this an internally generated subrequest? */
078:            boolean internal_subrequest = false;
079:
080:            // Constructors
081:
082:            /**
083:             * Creates a new request structure.
084:             *
085:             * @param con      the current HTTPConnection
086:             * @param method   the request method
087:             * @param req_uri  the request-uri
088:             * @param headers  the request headers
089:             * @param data     the entity as a byte[]
090:             * @param stream   the entity as a stream
091:             * @param allow_ui allow user interaction
092:             */
093:            public Request(HTTPConnection con, String method, String req_uri,
094:                    NVPair[] headers, byte[] data, HttpOutputStream stream,
095:                    boolean allow_ui) {
096:                this .connection = con;
097:                this .method = method;
098:                setRequestURI(req_uri);
099:                setHeaders(headers);
100:                this .data = data;
101:                this .stream = stream;
102:                this .allow_ui = allow_ui;
103:            }
104:
105:            // Methods
106:
107:            /**
108:             * @return the HTTPConnection this request is associated with
109:             */
110:            public HTTPConnection getConnection() {
111:                return connection;
112:            }
113:
114:            /**
115:             * @param con the HTTPConnection this request is associated with
116:             */
117:            public void setConnection(HTTPConnection con) {
118:                this .connection = con;
119:            }
120:
121:            /**
122:             * @return the request method
123:             */
124:            public String getMethod() {
125:                return method;
126:            }
127:
128:            /**
129:             * @param method the request method (e.g. GET, POST, etc)
130:             */
131:            public void setMethod(String method) {
132:                this .method = method;
133:            }
134:
135:            /**
136:             * @return the request-uri
137:             */
138:            public String getRequestURI() {
139:                return req_uri;
140:            }
141:
142:            /**
143:             * @param req_uri the request-uri
144:             */
145:            public void setRequestURI(String req_uri) {
146:                if (req_uri != null && req_uri.trim().length() > 0) {
147:                    req_uri = req_uri.trim();
148:                    if (req_uri.charAt(0) != '/' && !req_uri.equals("*")
149:                            && !method.equals("CONNECT"))
150:                        req_uri = "/" + req_uri;
151:                    this .req_uri = req_uri;
152:                } else
153:                    this .req_uri = "/";
154:            }
155:
156:            /**
157:             * @return the headers making up this request
158:             */
159:            public NVPair[] getHeaders() {
160:                return headers;
161:            }
162:
163:            /**
164:             * @param headers the headers for this request
165:             */
166:            public void setHeaders(NVPair[] headers) {
167:                if (headers != null)
168:                    this .headers = headers;
169:                else
170:                    this .headers = empty;
171:            }
172:
173:            /**
174:             * @return the body of this request
175:             */
176:            public byte[] getData() {
177:                return data;
178:            }
179:
180:            /**
181:             * @param data the entity for this request
182:             */
183:            public void setData(byte[] data) {
184:                this .data = data;
185:            }
186:
187:            /**
188:             * @return the output stream on which the body is written
189:             */
190:            public HttpOutputStream getStream() {
191:                return stream;
192:            }
193:
194:            /**
195:             * @param stream an output stream on which the entity is written
196:             */
197:            public void setStream(HttpOutputStream stream) {
198:                this .stream = stream;
199:            }
200:
201:            /**
202:             * @return true if the modules or handlers for this request may popup
203:             *         windows or otherwise interact with the user
204:             */
205:            public boolean allowUI() {
206:                return allow_ui;
207:            }
208:
209:            /**
210:             * @param allow_ui are modules and handlers allowed to popup windows or
211:             *                otherwise interact with the user?
212:             */
213:            public void setAllowUI(boolean allow_ui) {
214:                this .allow_ui = allow_ui;
215:            }
216:
217:            /**
218:             * @return a string containing the method and request-uri
219:             */
220:            public String toString() {
221:                return getClass().getName() + ": " + method + " " + req_uri;
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.