Source Code Cross Referenced for DefaultModule.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:         * @(#)DefaultModule.java				0.3-2 18/06/1999
003:         *
004:         *  This file is part of the HTTPClient package
005:         *  Copyright (C) 1996-1999  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:        import java.io.IOException;
032:        import java.net.ProtocolException;
033:
034:        /**
035:         * This is the default module which gets called after all other modules
036:         * have done their stuff.
037:         *
038:         * @version	0.3-2  18/06/1999
039:         * @author	Ronald Tschalär
040:         */
041:
042:        class DefaultModule implements  HTTPClientModule, GlobalConstants {
043:            /** number of times the request will be retried */
044:            private int req_timeout_retries;
045:
046:            // Constructors
047:
048:            /**
049:             * Three retries upon receipt of a 408.
050:             */
051:            DefaultModule() {
052:                req_timeout_retries = 3;
053:            }
054:
055:            // Methods
056:
057:            /**
058:             * Invoked by the HTTPClient.
059:             */
060:            public int requestHandler(Request req, Response[] resp) {
061:                return REQ_CONTINUE;
062:            }
063:
064:            /**
065:             * Invoked by the HTTPClient.
066:             */
067:            public void responsePhase1Handler(Response resp, RoRequest req) {
068:            }
069:
070:            /**
071:             * Invoked by the HTTPClient.
072:             */
073:            public int responsePhase2Handler(Response resp, Request req)
074:                    throws IOException {
075:                /* handle various response status codes until satisfied */
076:
077:                int sts = resp.getStatusCode();
078:                switch (sts) {
079:                case 408: // Request Timeout
080:
081:                    if (req_timeout_retries-- == 0 || req.getStream() != null) {
082:                        if (DebugMods)
083:                            System.err.println("DefM:  Status " + sts + " "
084:                                    + resp.getReasonLine() + " not handled - "
085:                                    + "maximum number of retries exceeded");
086:
087:                        return RSP_CONTINUE;
088:                    } else {
089:                        if (DebugMods)
090:                            System.err.println("DefM:  Handling " + sts + " "
091:                                    + resp.getReasonLine() + " - "
092:                                    + "resending request");
093:
094:                        return RSP_REQUEST;
095:                    }
096:
097:                case 411: // Length Required
098:                    if (req.getStream() != null
099:                            && req.getStream().getLength() == -1)
100:                        return RSP_CONTINUE;
101:
102:                    try {
103:                        resp.getInputStream().close();
104:                    } catch (IOException ioe) {
105:                    }
106:                    if (req.getData() != null)
107:                        throw new ProtocolException(
108:                                "Received status code 411 even"
109:                                        + " though Content-Length was sent");
110:
111:                    if (DebugMods)
112:                        System.err.println("DefM:  Handling " + sts + " "
113:                                + resp.getReasonLine() + " - resending "
114:                                + "request with 'Content-length: 0'");
115:
116:                    req.setData(new byte[0]); // will send Content-Length: 0
117:                    return RSP_REQUEST;
118:
119:                case 505: // HTTP Version not supported
120:                    return RSP_CONTINUE;
121:
122:                default:
123:                    return RSP_CONTINUE;
124:                }
125:            }
126:
127:            /**
128:             * Invoked by the HTTPClient.
129:             */
130:            public void responsePhase3Handler(Response resp, RoRequest req) {
131:            }
132:
133:            /**
134:             * Invoked by the HTTPClient.
135:             */
136:            public void trailerHandler(Response resp, RoRequest req) {
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.