abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1220938 - in /abdera/abdera2: client/src/main/java/org/apache/abdera2/protocol/client/ common/src/main/java/org/apache/abdera2/common/http/ core/src/main/java/org/apache/abdera2/protocol/client/
Date Mon, 19 Dec 2011 20:36:21 GMT
Author: jmsnell
Date: Mon Dec 19 20:36:21 2011
New Revision: 1220938

URL: http://svn.apache.org/viewvc?rev=1220938&view=rev
Log:
Update for the current draft of the Preference header. Also, include the ability to add the
Date header to the request

Modified:
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/BasicClient.java
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Client.java
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java

Modified: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/BasicClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/BasicClient.java?rev=1220938&r1=1220937&r2=1220938&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/BasicClient.java
(original)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/BasicClient.java
Mon Dec 19 20:36:21 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.abdera2.protocol.client;
 
+import java.io.IOException;
 import java.net.ProxySelector;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -26,7 +27,9 @@ import java.util.List;
 
 import org.apache.abdera2.common.anno.AnnoUtil;
 import org.apache.abdera2.common.anno.Version;
+import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.auth.AuthScope;
@@ -49,9 +52,11 @@ import org.apache.http.impl.client.Defau
 import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.impl.cookie.BasicClientCookie;
+import org.apache.http.impl.cookie.DateUtils;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HttpContext;
 
 @Version(value="v2.0-SNAPSHOT",
     name="Abdera",
@@ -560,4 +565,18 @@ public class BasicClient implements Clie
     Version version = AnnoUtil.getVersion(BasicClient.class);
     return String.format("%s/%s",version.name(),version.value());
   }
+  
+  public void includeRequestDateHeader() {
+    this.addRequestInterceptor(
+      new HttpRequestInterceptor() {
+        public void process(
+          HttpRequest request, 
+          HttpContext context)
+            throws HttpException, IOException {
+          request.setHeader(
+            "Date", 
+            DateUtils.formatDate(new Date()));
+        }}, 
+      -1);
+  }
 }

Modified: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Client.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Client.java?rev=1220938&r1=1220937&r2=1220938&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Client.java (original)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Client.java Mon
Dec 19 20:36:21 2011
@@ -240,5 +240,13 @@ public interface Client {
   <T extends Session>T newSession();
 
   void shutdown();
+  
+  /**
+   * Registers a request interceptor that adds 
+   * the Date header to the request. This header
+   * needs to reflect as accurately as possible
+   * the time when the request is actually sent.
+   */
+  void includeRequestDateHeader();
 
 }
\ No newline at end of file

Modified: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientWrapper.java?rev=1220938&r1=1220937&r2=1220938&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientWrapper.java
(original)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientWrapper.java
Mon Dec 19 20:36:21 2011
@@ -225,4 +225,8 @@ public abstract class ClientWrapper 
     internal.shutdown();
   }
 
+  public void includeRequestDateHeader() {
+    internal.includeRequestDateHeader();
+  }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java?rev=1220938&r1=1220937&r2=1220938&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java Mon
Dec 19 20:36:21 2011
@@ -48,10 +48,10 @@ import com.google.common.collect.Immutab
 public class Preference implements Serializable {
   
   public static final String RETURN_MINIMAL = "return-minimal";
-  public static final String RETURN_ACCEPTED = "return-accepted";
+  public static final String RETURN_ASYNCH = "return-asynch";
   public static final String RETURN_REPRESENTATION = "return-representation";
   public static final String WAIT = "wait";
-  public static final String STRICT= "strict";
+  public static final String STRICT = "strict";
   public static final String LENIENT = "lenient";
   
   public static final Preference PREF_STRICT = new Preference(STRICT);
@@ -73,8 +73,8 @@ public class Preference implements Seria
    * the server respond with a 202 Accepted response indicating that the
    * request has been accepted for processing.
    */
-  public static final Preference PREF_RETURN_ACCEPTED =
-    new Preference(RETURN_ACCEPTED);
+  public static final Preference PREF_RETURN_ASYNCH =
+    new Preference(RETURN_ASYNCH);
   
   /**
    * The "return-content" token indicates that the client prefers that the
@@ -366,6 +366,14 @@ public class Preference implements Seria
     return false;
   }
   
+  public static Iterable<Preference> concat(Preference pref, Preference... prefs) {
+    return ImmutableSet
+      .<Preference>builder()
+      .add(pref)
+      .add(prefs)
+      .build();
+  }
+  
   /**
    * Utility method that checks to see if the given token is included
    * in the collection of preference

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java?rev=1220938&r1=1220937&r2=1220938&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java
Mon Dec 19 20:36:21 2011
@@ -136,6 +136,5 @@ public class AbderaClient extends Client
   public <T extends Session>T newSession() {
     return (T)new AbderaSession(this);
   }
-
   
 }



Mime
View raw message