Source Code Cross Referenced for OptionsMethod.java in  » Net » Apache-common-HttpClient » org » apache » commons » httpclient » methods » 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 » Apache common HttpClient » org.apache.commons.httpclient.methods 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java,v 1.15 2004/04/18 23:51:37 jsdever Exp $
003:         * $Revision: 480424 $
004:         * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005:         *
006:         * ====================================================================
007:         *
008:         *  Licensed to the Apache Software Foundation (ASF) under one or more
009:         *  contributor license agreements.  See the NOTICE file distributed with
010:         *  this work for additional information regarding copyright ownership.
011:         *  The ASF licenses this file to You under the Apache License, Version 2.0
012:         *  (the "License"); you may not use this file except in compliance with
013:         *  the License.  You may obtain a copy of the License at
014:         *
015:         *      http://www.apache.org/licenses/LICENSE-2.0
016:         *
017:         *  Unless required by applicable law or agreed to in writing, software
018:         *  distributed under the License is distributed on an "AS IS" BASIS,
019:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020:         *  See the License for the specific language governing permissions and
021:         *  limitations under the License.
022:         * ====================================================================
023:         *
024:         * This software consists of voluntary contributions made by many
025:         * individuals on behalf of the Apache Software Foundation.  For more
026:         * information on the Apache Software Foundation, please see
027:         * <http://www.apache.org/>.
028:         *
029:         */
030:
031:        package org.apache.commons.httpclient.methods;
032:
033:        import org.apache.commons.httpclient.Header;
034:        import org.apache.commons.httpclient.HttpConnection;
035:        import org.apache.commons.httpclient.HttpMethodBase;
036:        import org.apache.commons.httpclient.HttpState;
037:
038:        import org.apache.commons.logging.LogFactory;
039:        import org.apache.commons.logging.Log;
040:        import java.util.Enumeration;
041:        import java.util.StringTokenizer;
042:        import java.util.Vector;
043:
044:        /**
045:         * Implements the HTTP OPTIONS method.
046:         * <p>
047:         * The HTTP OPTIONS method is defined in section 9.2 of 
048:         * <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
049:         * <blockquote>
050:         *  The OPTIONS method represents a request for information about the
051:         *  communication options available on the request/response chain
052:         *  identified by the Request-URI. This method allows the client to
053:         *  determine the options and/or requirements associated with a resource,
054:         *  or the capabilities of a server, without implying a resource action
055:         *  or initiating a resource retrieval.
056:         * </blockquote>
057:         * </p>
058:         *
059:         * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
060:         * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
061:         * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
062:         *
063:         * @version $Revision: 480424 $
064:         * @since 1.0
065:         */
066:        public class OptionsMethod extends HttpMethodBase {
067:
068:            // --------------------------------------------------------- Class Variables
069:
070:            /** Log object for this class. */
071:            private static final Log LOG = LogFactory
072:                    .getLog(OptionsMethod.class);
073:
074:            // ----------------------------------------------------------- Constructors
075:
076:            /**
077:             * Method constructor.
078:             *
079:             * @since 1.0
080:             */
081:            public OptionsMethod() {
082:            }
083:
084:            /**
085:             * Constructor specifying a URI.
086:             *
087:             * @param uri either an absolute or relative URI
088:             *
089:             * @since 1.0
090:             */
091:            public OptionsMethod(String uri) {
092:                super (uri);
093:            }
094:
095:            // ----------------------------------------------------- Instance Variables
096:
097:            /**
098:             * Methods allowed.
099:             */
100:            private Vector methodsAllowed = new Vector();
101:
102:            // --------------------------------------------------------- Public Methods
103:
104:            /**
105:             * Get the name.
106:             * @return "OPTIONS"
107:             * @since 2.0
108:             */
109:            public String getName() {
110:                return "OPTIONS";
111:            }
112:
113:            /**
114:             * Is the specified method allowed ?
115:             * 
116:             * @param method The method to check.
117:             * @return true if the specified method is allowed.
118:             * @since 1.0
119:             */
120:            public boolean isAllowed(String method) {
121:                checkUsed();
122:                return methodsAllowed.contains(method);
123:            }
124:
125:            /**
126:             * Get a list of allowed methods.
127:             * @return An enumeration of all the allowed methods.
128:             *
129:             * @since 1.0
130:             */
131:            public Enumeration getAllowedMethods() {
132:                checkUsed();
133:                return methodsAllowed.elements();
134:            }
135:
136:            // ----------------------------------------------------- HttpMethod Methods
137:
138:            /**
139:             * <p>
140:             * This implementation will parse the <tt>Allow</tt> header to obtain 
141:             * the set of methods supported by the resource identified by the Request-URI.
142:             * </p>
143:             *
144:             * @param state the {@link HttpState state} information associated with this method
145:             * @param conn the {@link HttpConnection connection} used to execute
146:             *        this HTTP method
147:             *
148:             * @see #readResponse
149:             * @see #readResponseHeaders
150:             * @since 2.0
151:             */
152:            protected void processResponseHeaders(HttpState state,
153:                    HttpConnection conn) {
154:                LOG
155:                        .trace("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)");
156:
157:                Header allowHeader = getResponseHeader("allow");
158:                if (allowHeader != null) {
159:                    String allowHeaderValue = allowHeader.getValue();
160:                    StringTokenizer tokenizer = new StringTokenizer(
161:                            allowHeaderValue, ",");
162:                    while (tokenizer.hasMoreElements()) {
163:                        String methodAllowed = tokenizer.nextToken().trim()
164:                                .toUpperCase();
165:                        methodsAllowed.addElement(methodAllowed);
166:                    }
167:                }
168:            }
169:
170:            /**
171:             * Return true if the method needs a content-length header in the request.
172:             *
173:             * @return true if a content-length header will be expected by the server
174:             *
175:             * @since 1.0
176:             * 
177:             * @deprecated only entity enclosing methods set content length header
178:             */
179:            public boolean needContentLength() {
180:                return false;
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.