abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r541778 - in /incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client: RequestOptions.java util/MethodHelper.java
Date Fri, 25 May 2007 20:43:47 GMT
Author: jmsnell
Date: Fri May 25 13:43:46 2007
New Revision: 541778

URL: http://svn.apache.org/viewvc?view=rev&rev=541778
Log:
Support for the X-HTTP-Method-Override header.

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/MethodHelper.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java?view=diff&rev=541778&r1=541777&r2=541778
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
Fri May 25 13:43:46 2007
@@ -42,6 +42,7 @@
   private boolean noLocalCache = false;
   private boolean revalidateAuth = false;
   private boolean useChunked = false;
+  private boolean usePostOverride = false;
   
   private final Map<String,List<String>> headers;  
   
@@ -435,5 +436,19 @@
    */
   public void setUseChunked(boolean useChunked) {
     this.useChunked = useChunked;
+  }
+
+  /**
+   * Set whether the request should use the X-HTTP-Method-Override option
+   */
+  public void setUsePostOverride(boolean useOverride) {
+    this.usePostOverride = useOverride;
+  }
+  
+  /**
+   * Return whether the request should use the X-HTTP-Method-Override option
+   */
+  public boolean isUsePostOverride() {
+    return this.usePostOverride;
   }
 }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/MethodHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/MethodHelper.java?view=diff&rev=541778&r1=541777&r2=541778
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/MethodHelper.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/util/MethodHelper.java
Fri May 25 13:43:46 2007
@@ -124,7 +124,16 @@
     RequestOptions options) {
       if (method == null) return null;
       Method m = Method.fromString(method);
+      Method actual = null;
       HttpMethod httpMethod = null;
+      if (options.isUsePostOverride()) {
+        if (m.equals(Method.PUT)) {
+          actual = m;
+        } else if (m.equals(Method.DELETE)) {
+          actual = m;
+        }
+        if (actual != null) m = Method.POST;
+      }
       switch(m) {
         case GET:     httpMethod = new GetMethod(uri); break;
         case POST:    httpMethod = getMethod(new PostMethod(uri), entity); break;
@@ -134,6 +143,9 @@
         case OPTIONS: httpMethod = new OptionsMethod(uri); break;
         case TRACE:   httpMethod = new TraceMethod(uri); break;
         default:      httpMethod = getMethod(new ExtensionMethod(method,uri), entity);
+      }
+      if (actual != null) {
+        httpMethod.addRequestHeader("X-HTTP-Method-Override", actual.name());
       }
       initHeaders(options, httpMethod);
       return httpMethod;



Mime
View raw message