1 31 32 package org.apache.commons.httpclient.methods; 33 34 import org.apache.commons.httpclient.Header; 35 import org.apache.commons.httpclient.HttpConnection; 36 import org.apache.commons.httpclient.HttpMethodBase; 37 import org.apache.commons.httpclient.HttpState; 38 39 import org.apache.commons.logging.LogFactory; 40 import org.apache.commons.logging.Log; 41 import java.util.Enumeration ; 42 import java.util.StringTokenizer ; 43 import java.util.Vector ; 44 45 46 68 public class OptionsMethod 69 extends HttpMethodBase { 70 71 72 74 75 private static final Log LOG = LogFactory.getLog(OptionsMethod.class); 76 77 79 80 85 public OptionsMethod() { 86 } 87 88 89 96 public OptionsMethod(String uri) { 97 super(uri); 98 } 99 100 101 103 104 107 private Vector methodsAllowed = new Vector (); 108 109 110 112 117 public String getName() { 118 return "OPTIONS"; 119 } 120 121 122 129 public boolean isAllowed(String method) { 130 checkUsed(); 131 return methodsAllowed.contains(method); 132 } 133 134 135 141 public Enumeration getAllowedMethods() { 142 checkUsed(); 143 return methodsAllowed.elements(); 144 } 145 146 147 149 163 protected void processResponseHeaders(HttpState state, HttpConnection conn) { 164 LOG.trace("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)"); 165 166 Header allowHeader = getResponseHeader("allow"); 167 if (allowHeader != null) { 168 String allowHeaderValue = allowHeader.getValue(); 169 StringTokenizer tokenizer = 170 new StringTokenizer (allowHeaderValue, ","); 171 while (tokenizer.hasMoreElements()) { 172 String methodAllowed = 173 tokenizer.nextToken().trim().toUpperCase(); 174 methodsAllowed.addElement(methodAllowed); 175 } 176 } 177 } 178 179 186 public boolean needContentLength() { 187 return false; 188 } 189 190 191 } 192 | Popular Tags |