abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1239261 [1/2] - in /abdera/abdera2: ./ activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/extra/ client/src/main/java/org/apache/abdera2/protocol/client/ common/ common/src...
Date Wed, 01 Feb 2012 18:49:12 GMT
Author: jmsnell
Date: Wed Feb  1 18:49:11 2012
New Revision: 1239261

URL: http://svn.apache.org/viewvc?rev=1239261&view=rev
Log:
some additional refactoring to simplify the overall project structure. this eliminates the separate generic client jar by moving that package into the common area... implementation experience has shown that the client code pretty much will need to go everywhere the rest of the code goes so it really didn't make sense to have that off in it's own separate thing... this gives us (and developers) one less jar to keep track of... which is always a good thing.

Added:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestOptions.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Session.java   (with props)
Removed:
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientBatchPusher.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientPusher.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OAuth2Helper.java
    abdera/abdera2/common/pom.xml
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClient.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponse.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaSession.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/history/FeedPagingHelper.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlHelper.java
    abdera/abdera2/pom.xml
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/CacheTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/ClientTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/anno/AnnoUtilTest.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java Wed Feb  1 18:49:11 2012
@@ -22,12 +22,12 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.IO;
-import org.apache.abdera2.protocol.client.BasicCachingClient;
-import org.apache.abdera2.protocol.client.BasicClient;
-import org.apache.abdera2.protocol.client.Client;
-import org.apache.abdera2.protocol.client.ClientWrapper;
-import org.apache.abdera2.protocol.client.RequestOptions;
-import org.apache.abdera2.protocol.client.Session;
+import org.apache.abdera2.common.protocol.BasicCachingClient;
+import org.apache.abdera2.common.protocol.BasicClient;
+import org.apache.abdera2.common.protocol.Client;
+import org.apache.abdera2.common.protocol.ClientWrapper;
+import org.apache.abdera2.common.protocol.RequestOptions;
+import org.apache.abdera2.common.protocol.Session;
 
 /**
  * Extension of the base Abdera Client that provides methods

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientBatchPusher.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientBatchPusher.java?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientBatchPusher.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientBatchPusher.java Wed Feb  1 18:49:11 2012
@@ -19,8 +19,8 @@ package org.apache.abdera2.activities.cl
 
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.common.protocol.RequestOptions;
 import org.apache.abdera2.common.pusher.Pusher;
-import org.apache.abdera2.protocol.client.RequestOptions;
 
 /**
  * Identical to ActivitiesClientPusher with the exception that the 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientPusher.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientPusher.java?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientPusher.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClientPusher.java Wed Feb  1 18:49:11 2012
@@ -20,10 +20,10 @@ package org.apache.abdera2.activities.cl
 import java.util.concurrent.ExecutorService;
 
 import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.common.protocol.ClientResponse;
+import org.apache.abdera2.common.protocol.RequestOptions;
+import org.apache.abdera2.common.protocol.Session.Listener;
 import org.apache.abdera2.common.pusher.Pusher;
-import org.apache.abdera2.protocol.client.ClientResponse;
-import org.apache.abdera2.protocol.client.Session.Listener;
-import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java Wed Feb  1 18:49:11 2012
@@ -30,12 +30,12 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.protocol.Client;
+import org.apache.abdera2.common.protocol.ClientResponse;
 import org.apache.abdera2.common.protocol.ProtocolException;
-import org.apache.abdera2.protocol.client.Client;
-import org.apache.abdera2.protocol.client.ClientResponse;
-import org.apache.abdera2.protocol.client.RequestHelper;
-import org.apache.abdera2.protocol.client.RequestOptions;
-import org.apache.abdera2.protocol.client.Session;
+import org.apache.abdera2.common.protocol.RequestHelper;
+import org.apache.abdera2.common.protocol.RequestOptions;
+import org.apache.abdera2.common.protocol.Session;
 import org.joda.time.DateTime;
 
 /**

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OAuth2Helper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OAuth2Helper.java?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OAuth2Helper.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OAuth2Helper.java Wed Feb  1 18:49:11 2012
@@ -22,13 +22,13 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.protocol.BasicClient;
+import org.apache.abdera2.common.protocol.Client;
+import org.apache.abdera2.common.protocol.ClientResponse;
+import org.apache.abdera2.common.protocol.RequestOptions;
+import org.apache.abdera2.common.protocol.Session;
 import org.apache.abdera2.common.templates.MapContext;
 import org.apache.abdera2.common.templates.QueryContext;
-import org.apache.abdera2.protocol.client.BasicClient;
-import org.apache.abdera2.protocol.client.Client;
-import org.apache.abdera2.protocol.client.ClientResponse;
-import org.apache.abdera2.protocol.client.RequestOptions;
-import org.apache.abdera2.protocol.client.Session;
 import org.apache.http.entity.StringEntity;
 
 /**

Modified: abdera/abdera2/common/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/pom.xml?rev=1239261&r1=1239260&r2=1239261&view=diff
==============================================================================
--- abdera/abdera2/common/pom.xml (original)
+++ abdera/abdera2/common/pom.xml Wed Feb  1 18:49:11 2012
@@ -85,5 +85,25 @@
       <artifactId>joda-time</artifactId>
     </dependency>
 
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpclient</artifactId>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpmime</artifactId>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpcore</artifactId>
+      </dependency>
+         
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpclient-cache</artifactId>
+      </dependency>
+
   </dependencies>
 </project>

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.cache.HttpCacheStorage;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.cache.CacheConfig;
+import org.apache.http.impl.client.cache.CachingHttpClient;
+
+/**
+ * Alternative implementation of the Abdera Client that uses client-side 
+ * Caching. This is intended to be used as a drop-in replacement to the 
+ * base Client when caching capabilities are desired.
+ */
+public class BasicCachingClient extends BasicClient implements CachingClient {
+
+  private DefaultHttpClient inner;
+  private HttpCacheStorage store;
+    
+  public BasicCachingClient(HttpCacheStorage store) {
+    this(DEFAULT_USER_AGENT, store);
+  }
+  
+  public BasicCachingClient(String useragent, HttpCacheStorage store) {
+      this.store = store;
+      this.client = initClient(useragent);
+  }
+  
+  public BasicCachingClient(DefaultHttpClient client, HttpCacheStorage store) {
+      this.store = store;
+      this.inner = client;
+      this.client = initClient(DEFAULT_USER_AGENT); // TODO:
+  }
+  
+  public BasicCachingClient() {
+    super();
+  }
+
+  public BasicCachingClient(DefaultHttpClient client) {
+    this.inner = client;
+    this.client = initClient(DEFAULT_USER_AGENT);
+  }
+
+  public BasicCachingClient(String useragent) {
+    super(useragent);
+  }
+
+  protected HttpClient initClient(String useragent) {
+    return initClient(useragent,inner);
+  }
+  
+  protected HttpClient initClient(String useragent, DefaultHttpClient client) {
+    inner = client != null? client : (DefaultHttpClient) super.initClient(useragent);
+    CacheConfig cacheConfig = new CacheConfig();  
+    cacheConfig.setMaxCacheEntries(1000);
+    cacheConfig.setMaxObjectSizeBytes(8192);
+    cacheConfig.setHeuristicCachingEnabled(true);
+
+    return store != null ? 
+        new CachingHttpClient(inner,store,cacheConfig):
+        new CachingHttpClient(inner, cacheConfig);
+  }
+  
+  public DefaultHttpClient getDefaultHttpClient() {
+    return inner;
+  }
+  
+  public long cacheHits() {
+    return ((CachingHttpClient)getClient()).getCacheHits();
+  }
+  
+  public long cacheMisses() {
+    return ((CachingHttpClient)getClient()).getCacheMisses();
+  }
+  
+  public long cacheUpdates() {
+    return ((CachingHttpClient)getClient()).getCacheUpdates();
+  }
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCachingClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,598 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.io.IOException;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Date;
+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;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.auth.params.AuthPNames;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.client.params.CookiePolicy;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.params.ConnRoutePNames;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.scheme.SchemeSocketFactory;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.DefaultHttpClient;
+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",
+    uri="http://abdera.apache.org")
+@SuppressWarnings("unchecked")
+public class BasicClient implements Client {
+
+  protected HttpClient client;
+  
+  public BasicClient() {
+    this(DEFAULT_USER_AGENT);
+  }
+  
+  public BasicClient(String useragent) {
+      this.client = initClient(useragent);
+  }
+  
+  public BasicClient(DefaultHttpClient client) {
+    this.client = client;
+  }
+    
+  /**
+   * Default initialization of the Scheme Registry, subclasses
+   * may overload this to customize the scheme registry 
+   * configuration
+   */
+  protected SchemeRegistry initSchemeRegistry() {
+    SchemeRegistry schemeRegistry = new SchemeRegistry();
+    schemeRegistry.register(
+      new Scheme(
+        "http", 
+        80, 
+        PlainSocketFactory.getSocketFactory()));
+    schemeRegistry.register(
+      new Scheme(
+        "https", 
+        443, 
+        SSLSocketFactory.getSocketFactory()));
+    return schemeRegistry;
+  }
+  
+  /**
+   * Default initialization of the Client Connection Manager,
+   * subclasses may overload this to customize the connection
+   * manager configuration
+   */
+  protected ClientConnectionManager initConnectionManager(SchemeRegistry sr) {
+    ThreadSafeClientConnManager cm = 
+      new ThreadSafeClientConnManager(sr);
+    cm.setDefaultMaxPerRoute(initDefaultMaxConnectionsPerRoute());
+    cm.setMaxTotal(initDefaultMaxTotalConnections());    
+    return cm;
+  }
+  
+  protected int initDefaultMaxConnectionsPerRoute() {
+    return DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
+  }
+  
+  protected int initDefaultMaxTotalConnections() {
+    return DEFAULT_MAX_TOTAL_CONNECTIONS;
+  }
+  
+  protected void initDefaultParameters(HttpParams params) {
+    params.setParameter(
+      CoreProtocolPNames.USE_EXPECT_CONTINUE, 
+      Boolean.TRUE);
+    params.setParameter(
+      ClientPNames.MAX_REDIRECTS, 
+      DEFAULT_MAX_REDIRECTS);
+    params.setParameter(
+      ClientPNames.COOKIE_POLICY, 
+      CookiePolicy.BROWSER_COMPATIBILITY); 
+  }
+  
+  protected HttpClient initClient(String useragent) {
+    SchemeRegistry schemeRegistry = 
+      initSchemeRegistry();
+    ClientConnectionManager cm = 
+      initConnectionManager(schemeRegistry);
+    DefaultHttpClient client = new DefaultHttpClient(cm);
+    HttpParams params = client.getParams();
+    params.setParameter(CoreProtocolPNames.USER_AGENT, useragent);
+    initDefaultParameters(params);
+    return client;
+  }
+  
+  public <T extends Client>T addRequestInterceptor(
+    HttpRequestInterceptor i, 
+    int index) {
+    if (index == -1)
+      getDefaultHttpClient().addRequestInterceptor(i);
+    else
+      getDefaultHttpClient().addRequestInterceptor(i, index);
+    return (T)this;
+  }
+  
+  public <T extends Client>T addResponseInterceptor(
+    HttpResponseInterceptor i, 
+    int index) {
+    if (index == -1)
+      getDefaultHttpClient().addResponseInterceptor(i);
+    else
+      getDefaultHttpClient().addResponseInterceptor(i, index);
+    return (T)this;
+  }
+  
+  public <T extends Client>T clearRequestInterceptors() {
+    getDefaultHttpClient().clearRequestInterceptors();
+    return (T)this;
+  }
+  
+  public <T extends Client>T clearResponseInterceptors() {
+    getDefaultHttpClient().clearResponseInterceptors();
+    return (T)this;
+  }
+  
+  public <T extends Client>T registerScheme(
+    String scheme, 
+    int port, 
+    SchemeSocketFactory factory) {
+    SchemeRegistry sr = 
+      getClient().getConnectionManager().getSchemeRegistry();
+    sr.register(new Scheme(scheme,port,factory));
+    return (T)this;
+  }
+  
+  public HttpClient getClient() {
+    return client;
+  }
+  
+  public DefaultHttpClient getDefaultHttpClient() {
+    return (DefaultHttpClient)client;
+  }
+  
+  public <T extends Client>T addCredentials(
+      String target, 
+      String realm,
+      String scheme,
+      String user,
+      String password) 
+        throws URISyntaxException {
+    return (T) addCredentials(
+      target,
+      realm,
+      scheme,
+      new UsernamePasswordCredentials(user,password));
+  }
+  
+  
+  /**
+   * Add authentication credentials
+   */
+  public <T extends Client>T addCredentials(
+    String target, 
+    String realm, 
+    String scheme, 
+    Credentials credentials)
+      throws URISyntaxException {
+    String host = AuthScope.ANY_HOST;
+    int port = AuthScope.ANY_PORT;
+    if (target != null) {
+        URI uri = new URI(target);
+        host = uri.getHost();
+        port = uri.getPort();
+    }
+    HttpHost targetHost = new HttpHost(host,port,scheme);
+    getDefaultHttpClient().getCredentialsProvider().setCredentials(
+        new AuthScope(
+            targetHost.getHostName(), 
+            targetHost.getPort(), 
+            realm != null ? realm : AuthScope.ANY_REALM, 
+            scheme != null ? scheme : AuthScope.ANY_SCHEME), 
+        credentials);
+     return (T)this;
+  }
+
+  /**
+   * When multiple authentication schemes are supported by a server, the client will automatically select a scheme
+   * based on the configured priority. For instance, to tell the client to prefer "digest" over "basic", set the
+   * priority by calling setAuthenticationSchemePriority("digest","basic")
+   */
+  public <T extends Client>T setAuthenticationSchemePriority(String... scheme) {
+      List<?> authPrefs = java.util.Arrays.asList(scheme);
+      client.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPrefs);
+      return (T)this;
+  }
+
+  /**
+   * Returns the current listing of preferred authentication schemes, in order of preference
+   * 
+   * @see setAuthenticationSchemePriority
+   */
+  public String[] getAuthenticationSchemePriority() {
+      List<?> list = (List<?>) client.getParams().getParameter(AuthPNames.TARGET_AUTH_PREF);
+      return list.toArray(new String[list.size()]);
+  }
+
+  /**
+   * Set the maximum number of connections allowed for a single host. This 
+   * is only effective if the Connection Manager implementation used is
+   * a ThreadSafeClientConnManager, otherwise, an IllegalStateException is
+   * thrown. Subclasses can override this method if a different Client
+   * Connection Manager implementation is used that supports setting the
+   * max connections per host.
+   */
+  public <T extends Client>T setMaxConnectionsPerHost(int max) {
+    ClientConnectionManager ccm = 
+      client.getConnectionManager();
+    if (ccm instanceof ThreadSafeClientConnManager) {
+      ThreadSafeClientConnManager cm = 
+        (ThreadSafeClientConnManager) ccm;
+      cm.setDefaultMaxPerRoute(max);
+    } else {
+      throw new IllegalStateException();
+    }
+    return (T)this;
+  }
+
+  /**
+   * Return the maximum number of connections allowed for a single host. This
+   * only returns a value if the Connection Manager implementation is a
+   * ThreadSafeClientConnManager instance, otherwise it returns -1. Subclasses
+   * can override this behavior if a different Connection Manager implementation
+   * is used.
+   */
+  public int getMaxConnectionsPerHost() {
+    ClientConnectionManager ccm = 
+      client.getConnectionManager();
+    if (ccm instanceof ThreadSafeClientConnManager) {
+      ThreadSafeClientConnManager cm = 
+        (ThreadSafeClientConnManager) client.getConnectionManager();
+      return cm.getDefaultMaxPerRoute();
+    } else return -1;
+  }
+
+  /**
+   * Return the maximum number of connections allowed for the client
+   */
+  public <T extends Client>T setMaxConnectionsTotal(int max) {
+    ClientConnectionManager ccm = 
+      client.getConnectionManager();
+    if (ccm instanceof ThreadSafeClientConnManager) {
+      ThreadSafeClientConnManager cm = 
+        (ThreadSafeClientConnManager) client.getConnectionManager();
+      cm.setMaxTotal(max);
+    } else {
+      throw new IllegalStateException();
+    }
+    return (T)this;
+  }
+
+  /**
+   * Return the maximum number of connections allowed for the client
+   */
+  public int getMaxConnectionsTotal() {
+    ClientConnectionManager ccm = 
+      client.getConnectionManager();
+    if (ccm instanceof ThreadSafeClientConnManager) {
+      ThreadSafeClientConnManager cm = 
+        (ThreadSafeClientConnManager) client.getConnectionManager();
+      return cm.getMaxTotal();
+    } return -1;
+  }
+
+  /**
+   * Configure the client to use the specified proxy
+   */
+  public <T extends Client>T setProxy(String host, int port) {
+      HttpHost proxy = 
+        new HttpHost(host, port);
+      client.getParams().setParameter(
+          ConnRoutePNames.DEFAULT_PROXY, proxy);
+      return (T)this;
+  }
+
+  /**
+   * Configure the client to use the proxy configured for the JVM
+   * @return
+   */
+  public <T extends Client>T setStandardProxy() {
+    ProxySelectorRoutePlanner routePlanner = 
+      new ProxySelectorRoutePlanner(
+        client.getConnectionManager().getSchemeRegistry(),
+        ProxySelector.getDefault());  
+    getDefaultHttpClient().setRoutePlanner(routePlanner);
+    return (T)this;
+  }
+  
+  /**
+   * Get the underlying HTTP Client's Cookie Store, creating it automatically
+   * if it does not already exist
+   */
+  public CookieStore getCookieStore() {
+    return getCookieStore(true);
+  }
+  
+  /**
+   * Get the underlying HTTP Client's Cookie Store, optionally creating it
+   * if it does not already exist
+   */
+  public CookieStore getCookieStore(boolean create) {
+    CookieStore store = getDefaultHttpClient().getCookieStore();
+    if (store == null && create) {
+      synchronized(this) {
+        store = new BasicCookieStore();
+        getDefaultHttpClient().setCookieStore(store);
+      }
+    }
+    return store;
+  }
+  
+  /**
+   * Set the underlying HTTP Client Cookie Store implementation
+   */
+  public <T extends Client>T setCookieStore(CookieStore cookieStore) {
+    getDefaultHttpClient().setCookieStore(cookieStore);
+    return (T)this;
+  }
+  
+  /**
+   * Manually add cookies
+   */
+  public <T extends Client>T addCookie(
+      String domain, 
+      String name, 
+      String value) {
+      BasicClientCookie cookie = 
+        new BasicClientCookie(name,value);
+      cookie.setVersion(0);
+      cookie.setDomain(domain);
+      getCookieStore().addCookie(cookie);
+      return (T)this;
+  }
+
+  /**
+   * Manually add cookies
+   */
+  public <T extends Client>T addCookie(
+    String domain, 
+    String name, 
+    String value, 
+    String path, 
+    Date expires, 
+    boolean secure) {
+    BasicClientCookie cookie = 
+      new BasicClientCookie(name,value);
+    cookie.setVersion(0);
+    cookie.setDomain(domain);
+    cookie.setPath(path);
+    cookie.setExpiryDate(expires);
+    cookie.setSecure(secure);
+    getCookieStore().addCookie(cookie);
+    return (T)this;
+  }
+
+  /**
+   * Manually add cookies
+   */
+  public <T extends Client>T addCookies(Cookie cookie) {
+      getCookieStore().addCookie(cookie);
+      return (T)this;
+  }
+
+  /**
+   * Manually add cookies
+   */
+  public <T extends Client>T addCookies(Cookie... cookies) {
+      for (Cookie cookie : cookies) 
+        getCookieStore().addCookie(cookie);
+      return (T)this;
+  }
+
+  /**
+   * Get all the cookies
+   */
+  public Iterable<Cookie> getCookies() {
+    return getCookieStore().getCookies();
+  }
+
+  /**
+   * Get the cookies for a specific domain and path
+   */
+  public Iterable<Cookie> getCookies(String domain, String path) {
+      List<Cookie> cookies = getCookieStore().getCookies();
+      List<Cookie> list = new ArrayList<Cookie>();
+      for (Cookie cookie : cookies) {
+          String test = cookie.getDomain();
+          if (test.startsWith("."))
+              test = test.substring(1);
+          if ((domain.endsWith(test) || test.endsWith(domain)) && 
+              (path == null || cookie.getPath().startsWith(path))) {
+              list.add(cookie);
+          }
+      }
+      return list;
+  }
+
+  /**
+   * Get the cookies for a specific domain
+   */
+  public Iterable<Cookie> getCookies(String domain) {
+      return getCookies(domain, null);
+  }
+
+  /**
+   * Clear the cookies
+   */
+  public <T extends Client>T clearCookies() {
+      getCookieStore().clear();
+      return (T)this;
+  }
+  
+  public <T extends Client>T clearExpiredCookies() {
+      getCookieStore().clearExpired(new Date());
+      return (T)this;
+  }
+
+  /**
+   * Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default
+   * value is zero.
+   */
+  public <T extends Client>T setConnectionTimeout(int timeout) {
+      client.getParams().setIntParameter(
+        CoreConnectionPNames.CONNECTION_TIMEOUT, 
+        Math.max(0,timeout));
+      return (T)this;
+  }
+
+  /**
+   * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout
+   * value of zero is interpreted as an infinite timeout.
+   */
+  public <T extends Client>T setSocketTimeout(int timeout) {
+    client.getParams().setIntParameter(
+      CoreConnectionPNames.SO_TIMEOUT, 
+      Math.max(0,timeout));
+      return (T)this;
+  }
+
+  /**
+   * Return the timeout until a connection is etablished, in milliseconds. A value of zero means the timeout is not
+   * used. The default value is zero.
+   */
+  public int getConnectionTimeout() {
+      return client.getParams().getIntParameter(
+        CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
+  }
+
+  /**
+   * Return the socket timeout for the connection in milliseconds A timeout value of zero is interpreted as an
+   * infinite timeout.
+   */
+  public int getSocketTimeout() {
+      return client.getParams().getIntParameter(
+        CoreConnectionPNames.SO_TIMEOUT, 0);
+  }
+
+  /**
+   * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve bandwidth by
+   * minimizing the number of segments that are sent. When applications wish to decrease network latency and increase
+   * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the
+   * cost of an increase in bandwidth consumption.
+   */
+  public void setTcpNoDelay(boolean enable) {
+      client.getParams().setBooleanParameter(
+        CoreConnectionPNames.TCP_NODELAY, enable);
+  }
+
+  /**
+   * Tests if Nagle's algorithm is to be used.
+   */
+  public boolean getTcpNoDelay() {
+    return client.getParams().getBooleanParameter(
+      CoreConnectionPNames.TCP_NODELAY, false);
+  }
+
+  /**
+   * Return the HttpConnectionManagerParams object of the underlying HttpClient. This enables you to configure options
+   * not explicitly exposed by the AbderaClient
+   */
+  public HttpParams getHttpConnectionManagerParams() {
+      return client.getParams();
+  }
+
+  /**
+   * Set the maximum number of redirects
+   */
+  public <T extends Client>T setMaximumRedirects(int redirects) {
+      client.getParams().setIntParameter(
+        ClientPNames.MAX_REDIRECTS, 
+        Math.max(0, redirects));
+      return (T)this;
+  }
+
+  /**
+   * Get the maximum number of redirects
+   */
+  public int getMaximumRedirects() {
+      return client.getParams().getIntParameter(
+        ClientPNames.MAX_REDIRECTS, 
+        DEFAULT_MAX_REDIRECTS);
+  }
+
+  /**
+   * Clear all credentials (including proxy credentials)
+   */
+  public <T extends Client>T clearCredentials() {
+      getDefaultHttpClient().getCredentialsProvider().clear();
+      return (T)this;
+  }
+
+  public <T extends Session>T newSession() {
+    return (T)new Session(this);
+  }
+  
+  public void shutdown() {
+    client.getConnectionManager().shutdown();
+  }
+
+  public static String getDefaultUserAgent() {
+    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);
+  }
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+public interface CachingClient extends Client {
+
+  long cacheHits();
+
+  long cacheMisses();
+
+  long cacheUpdates();
+
+}
\ No newline at end of file

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CachingClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.net.URISyntaxException;
+import java.util.Date;
+
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.scheme.SchemeSocketFactory;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.HttpParams;
+
+public interface Client {
+
+  public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 100;
+  public static final int DEFAULT_MAX_REDIRECTS = 10;
+  public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 2;
+  
+  // note... findbugs rightfully flags this as a possible bug 
+  // because it's a superclass referencing a static method on 
+  // a subclass, but because of the way the codes written, things
+  // work out.
+  public static final String DEFAULT_USER_AGENT = BasicClient.getDefaultUserAgent();
+
+  <T extends Client>T addRequestInterceptor(HttpRequestInterceptor i,
+      int index);
+
+  <T extends Client>T addResponseInterceptor(HttpResponseInterceptor i,
+      int index);
+
+  <T extends Client>T clearRequestInterceptors();
+
+  <T extends Client>T clearResponseInterceptors();
+
+  <T extends Client>T registerScheme(String scheme, int port,
+      SchemeSocketFactory factory);
+
+  HttpClient getClient();
+
+  DefaultHttpClient getDefaultHttpClient();
+
+  /**
+   * Add authentication credentials
+   */
+  <T extends Client>T addCredentials(String target, String realm,
+      String scheme, Credentials credentials) throws URISyntaxException;
+
+  /**
+   * Add username/password credentials
+   * @throws URISyntaxException 
+   */
+  <T extends Client>T addCredentials(
+    String target, 
+    String realm,
+    String scheme,
+    String user,
+    String password) throws URISyntaxException;
+  
+  /**
+   * When multiple authentication schemes are supported by a server, the client will automatically select a scheme
+   * based on the configured priority. For instance, to tell the client to prefer "digest" over "basic", set the
+   * priority by calling setAuthenticationSchemePriority("digest","basic")
+   */
+  <T extends Client>T setAuthenticationSchemePriority(String... scheme);
+
+  /**
+   * Returns the current listing of preferred authentication schemes, in order of preference
+   * 
+   * @see setAuthenticationSchemePriority
+   */
+  String[] getAuthenticationSchemePriority();
+
+  /**
+   * Set the maximum number of connections allowed for a single host. This 
+   * is only effective if the Connection Manager implementation used is
+   * a ThreadSafeClientConnManager, otherwise, an IllegalStateException is
+   * thrown. Subclasses can override this method if a different Client
+   * Connection Manager implementation is used that supports setting the
+   * max connections per host.
+   */
+  <T extends Client>T setMaxConnectionsPerHost(int max);
+
+  /**
+   * Return the maximum number of connections allowed for a single host. This
+   * only returns a value if the Connection Manager implementation is a
+   * ThreadSafeClientConnManager instance, otherwise it returns -1. Subclasses
+   * can override this behavior if a different Connection Manager implementation
+   * is used.
+   */
+  int getMaxConnectionsPerHost();
+
+  /**
+   * Return the maximum number of connections allowed for the client
+   */
+  <T extends Client>T setMaxConnectionsTotal(int max);
+
+  /**
+   * Return the maximum number of connections allowed for the client
+   */
+  int getMaxConnectionsTotal();
+
+  /**
+   * Configure the client to use the specified proxy
+   */
+  <T extends Client>T setProxy(String host, int port);
+
+  /**
+   * Configure the client to use the proxy configured for the JVM
+   * @return
+   */
+  <T extends Client>T setStandardProxy();
+
+  /**
+   * Get the underlying HTTP Client's Cookie Store, creating it automatically
+   * if it does not already exist
+   */
+  CookieStore getCookieStore();
+
+  /**
+   * Get the underlying HTTP Client's Cookie Store, optionally creating it
+   * if it does not already exist
+   */
+  CookieStore getCookieStore(boolean create);
+
+  /**
+   * Set the underlying HTTP Client Cookie Store implementation
+   */
+  <T extends Client>T setCookieStore(CookieStore cookieStore);
+
+  /**
+   * Manually add cookies
+   */
+  <T extends Client>T addCookie(String domain, String name, String value);
+
+  /**
+   * Manually add cookies
+   */
+  <T extends Client>T addCookie(String domain, String name, String value,
+      String path, Date expires, boolean secure);
+
+  /**
+   * Manually add cookies
+   */
+  <T extends Client>T addCookies(Cookie cookie);
+
+  /**
+   * Manually add cookies
+   */
+  <T extends Client>T addCookies(Cookie... cookies);
+
+  /**
+   * Get all the cookies
+   */
+  Iterable<Cookie> getCookies();
+
+  /**
+   * Get the cookies for a specific domain and path
+   */
+  Iterable<Cookie> getCookies(String domain, String path);
+
+  /**
+   * Get the cookies for a specific domain
+   */
+  Iterable<Cookie> getCookies(String domain);
+
+  /**
+   * Clear the cookies
+   */
+  <T extends Client>T clearCookies();
+
+  <T extends Client>T clearExpiredCookies();
+
+  /**
+   * Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default
+   * value is zero.
+   */
+  <T extends Client>T setConnectionTimeout(int timeout);
+
+  /**
+   * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout
+   * value of zero is interpreted as an infinite timeout.
+   */
+  <T extends Client>T setSocketTimeout(int timeout);
+
+  /**
+   * Return the timeout until a connection is etablished, in milliseconds. A value of zero means the timeout is not
+   * used. The default value is zero.
+   */
+  int getConnectionTimeout();
+
+  /**
+   * Return the socket timeout for the connection in milliseconds A timeout value of zero is interpreted as an
+   * infinite timeout.
+   */
+  int getSocketTimeout();
+
+  /**
+   * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve bandwidth by
+   * minimizing the number of segments that are sent. When applications wish to decrease network latency and increase
+   * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the
+   * cost of an increase in bandwidth consumption.
+   */
+  void setTcpNoDelay(boolean enable);
+
+  /**
+   * Tests if Nagle's algorithm is to be used.
+   */
+  boolean getTcpNoDelay();
+
+  /**
+   * Return the HttpConnectionManagerParams object of the underlying HttpClient. This enables you to configure options
+   * not explicitly exposed by the AbderaClient
+   */
+  HttpParams getHttpConnectionManagerParams();
+
+  /**
+   * Set the maximum number of redirects
+   */
+  <T extends Client>T setMaximumRedirects(int redirects);
+
+  /**
+   * Get the maximum number of redirects
+   */
+  int getMaximumRedirects();
+
+  /**
+   * Clear all credentials (including proxy credentials)
+   */
+  <T extends Client>T clearCredentials();
+
+  <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

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Client.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+
+import org.apache.abdera2.common.http.Method;
+import org.joda.time.DateTime;
+
+public interface ClientResponse extends Response {
+
+    Session getSession();
+  
+    /**
+     * Return the request method
+     */
+    Method getMethod();
+
+    /**
+     * Return the request URI. The request was redirected, this will return the new URI
+     */
+    String getUri();
+
+    /**
+     * Release the resources associated with this response
+     */
+    void release();
+
+    /**
+     * Returns the inputstream used to read data from this response
+     */
+    InputStream getInputStream() throws IOException;
+
+    /**
+     * Returns a reader used to read data from this response. Will use the character set declared in the Content-Type to
+     * create the reader
+     */
+    Reader getReader() throws IOException;
+
+    /**
+     * Returns a reader used to read data from this response. Will use the character set specified to create the reader
+     */
+    Reader getReader(String charset) throws IOException;
+
+    /**
+     * Return the server-specified date returned in the response
+     */
+    DateTime getServerDate();
+
+    /**
+     * Return the character set encoding specified in the ContentType header, if any
+     */
+    String getCharacterEncoding();
+
+    void writeTo(OutputStream out) throws IOException;
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponse.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParameterList;
+
+import org.apache.abdera2.common.http.Authentication;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.http.Method;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.ResponseType;
+import org.apache.abdera2.common.http.WebLink;
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.text.Codec;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.entity.BufferedHttpEntity;
+import org.apache.http.impl.cookie.DateUtils;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import static com.google.common.base.Preconditions.*;
+
+class ClientResponseImpl 
+  implements ClientResponse {
+
+  private final HttpResponse response;
+  private final Session session;
+  private final Method method;
+  private final HttpContext localContext;
+  private BufferedHttpEntity buffer;
+  
+  public ClientResponseImpl(
+    Session session,
+    HttpResponse response,
+    String method,
+    HttpContext localContext) {
+    this.response = response;
+    this.session = session;
+    this.method = Method.get(method,true);
+    this.localContext = localContext;
+  }
+  
+  public Session getSession() {
+    return session;
+  }
+  
+  public EntityTag getEntityTag() {
+    String et = getHeader("ETag");
+    return et != null ? new EntityTag(et) : null;
+  }
+
+  public ResponseType getType() {
+    return ResponseType.select(response.getStatusLine().getStatusCode());
+  }
+
+  public int getStatus() {
+    return response.getStatusLine().getStatusCode();
+  }
+
+  public String getStatusText() {
+    return response.getStatusLine().getReasonPhrase();
+  }
+
+  public DateTime getLastModified() {
+    return getDateHeader("Last-Modified");
+  }
+
+  public long getContentLength() {
+    try {
+      HttpEntity entity = getEntity();
+      return entity != null ? entity.getContentLength() : 0;
+    } catch (Throwable t) {
+      throw new RuntimeException(t);
+    }
+  }
+
+  public String getAllow() {
+    return getHeader("Allow");
+  }
+
+  public IRI getLocation() {
+    String l = getHeader("Location");
+    return l != null ? new IRI(l) : null;
+  }
+
+  public long getAge() {
+    String a = getHeader("Age");
+    return a != null ? Long.parseLong(a) : -1;
+  }
+
+  public DateTime getExpires() {
+    return getDateHeader("Expires");
+  }
+
+  public String getHeader(String name) {
+    Header header = response.getFirstHeader(name);
+    return header != null ? header.getValue() : null;
+  }
+
+  public String getDecodedHeader(String name) {
+    String val = getHeader(name);
+    return val != null ? Codec.decode(val) : null;
+  }
+
+  @SuppressWarnings("unchecked")
+  public Iterable<Object> getHeaders(String name) {
+    Header[] headers = response.getHeaders(name);
+    if (headers == null) return Collections.EMPTY_LIST;
+    List<Object> ret = new ArrayList<Object>();
+    for (int n = 0; n < headers.length; n++) 
+      ret.add(headers[n].getValue());
+    return ret;
+  }
+
+  public Iterable<String> getDecodedHeaders(String name) {
+    Iterable<Object> headers = getHeaders(name);
+    List<String> ret = new ArrayList<String>();
+    for (Object h : headers)
+      ret.add(Codec.decode(h.toString()));
+    return ret;
+  }
+
+  public Iterable<String> getHeaderNames() {
+    Header[] headers = response.getAllHeaders();
+    Set<String> set = new HashSet<String>();
+    for (Header header : headers)
+      set.add(header.getName());
+    return set;
+  }
+
+  public String getSlug() {
+    return getDecodedHeader("Slug");
+  }
+
+  public MimeType getContentType() {
+    try {
+      String ct = getHeader("Content-Type");
+      return ct != null ? new MimeType(ct) : null;
+    } catch (Throwable t) {
+      throw new RuntimeException(t);
+    }
+  }
+
+  public IRI getContentLocation() {
+    String ct = getHeader("Location");
+    return ct != null ? new IRI(ct) : null;
+  }
+
+  public String getContentLanguage() {
+    String ct = getHeader("Content-Language");
+    return ct != null ? new Lang(ct).toString() : null;
+  }
+
+  public DateTime getDateHeader(String name) {
+    try {
+      String ct = getHeader(name);
+      return ct != null ? new DateTime(DateUtils.parseDate(ct)) : null;
+    } catch (Throwable t) {
+      throw new RuntimeException(t);
+    }
+  }
+
+  public CacheControl getCacheControl() {
+    String cc = getHeader("Cache-Control");
+    return cc != null ? CacheControl.parse(cc) : null;
+  }
+
+  @SuppressWarnings("unchecked")
+  public Iterable<Authentication> getAuthentication() {
+    String cc = getHeader("WWW-Authenticate");
+    return cc != null ? Authentication.parse(cc) : Collections.EMPTY_LIST;
+  }
+
+  public Method getMethod() {
+    return method;
+  }
+
+  public String getUri() {
+    HttpUriRequest currentReq = 
+      (HttpUriRequest) localContext.getAttribute( 
+        ExecutionContext.HTTP_REQUEST);
+    HttpHost currentHost = (HttpHost)  localContext.getAttribute( 
+        ExecutionContext.HTTP_TARGET_HOST);
+    String currentUrl = currentHost.toURI() + currentReq.getURI();
+    return currentUrl;
+  }
+
+  public void release() {
+    try {
+      EntityUtils.consume(response.getEntity());
+    } catch (Throwable t) {}
+  }
+
+  private HttpEntity getEntity() throws IOException {
+    if (buffer == null) {
+      HttpEntity entity = response.getEntity();
+      if (entity != null)
+        buffer = new BufferedHttpEntity(response.getEntity());
+    }
+    return buffer;
+  }
+  
+  public InputStream getInputStream() throws IOException {
+    InputStream in = null;
+    String ce = getHeader("Content-Encoding");
+    HttpEntity entity = getEntity();
+    in = entity != null ? entity.getContent() : null;
+    if (ce != null && in != null)
+        in = Compression.wrap(in, ce);
+    return in;
+  }
+
+  public Reader getReader() throws IOException {
+    return getReader(getCharacterEncoding());
+  }
+
+  public Reader getReader(String charset) throws IOException {
+    InputStream in = getInputStream();
+    if (in == null) return null;
+    Reader reader = 
+      charset != null ? 
+          new InputStreamReader(getInputStream(),charset) :
+          new InputStreamReader(getInputStream());
+    return reader;
+  }
+
+  public DateTime getServerDate() {
+    return getDateHeader("Date");
+  }
+
+  @SuppressWarnings("rawtypes")
+  public String getCharacterEncoding() {
+    MimeType mt = this.getContentType();
+    if (mt != null) {
+      MimeTypeParameterList list = mt.getParameters();
+      Enumeration names = list.getNames();
+      while (names.hasMoreElements()) {
+        String name = (String) names.nextElement();
+        if (name.equalsIgnoreCase("charset"))
+          return list.get(name);
+      }
+    }
+    return "UTF-8";
+  }
+
+  public void writeTo(OutputStream out) throws IOException {
+    InputStream in = getInputStream();
+    byte[] buf = new byte[1024];
+    int r = -1;
+    while((r = in.read(buf)) > -1)
+      out.write(buf,0,r);
+  }
+
+  public Iterable<WebLink> getWebLinks() {
+    List<WebLink> links = new ArrayList<WebLink>();
+    Iterable<Object> headers = this.getHeaders("Link");
+    for (Object obj : headers) {
+      Iterable<WebLink> list = WebLink.parse(obj.toString());
+      for (WebLink link : list)
+        links.add(link);
+    }
+    return links;
+  }
+  
+  public Iterable<Preference> getPrefer() {
+    List<Preference> links = new ArrayList<Preference>();
+    Iterable<Object> headers = this.getHeaders("Prefer");
+    for (Object obj : headers) {
+      Iterable<Preference> list = Preference.parse(obj.toString());
+      for (Preference link : list)
+        links.add(link);
+    }
+    return links;
+  }
+
+  public <T> T getHeader(String name, Function<String, T> transform) {
+    checkNotNull(transform);
+    return transform.apply(getHeader(name));
+  }
+
+  public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+    Iterable<Object> objs = getHeaders(name);
+    List<T> list = new ArrayList<T>();
+    for (Object obj : objs)
+      list.add(transform.apply(obj.toString()));
+    return Iterables.unmodifiableIterable(list);
+  }
+}
\ No newline at end of file

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.http.Authentication;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.http.Method;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.ResponseType;
+import org.apache.abdera2.common.http.WebLink;
+import org.apache.abdera2.common.iri.IRI;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Function;
+
+public class ClientResponseWrapper 
+  implements ClientResponse {
+
+  private final ClientResponse internal;
+  
+  public ClientResponseWrapper(ClientResponse internal) {
+    this.internal = internal;
+  }
+  
+  public EntityTag getEntityTag() {
+    return internal.getEntityTag();
+  }
+
+  public ResponseType getType() {
+    return internal.getType();
+  }
+
+  public int getStatus() {
+    return internal.getStatus();
+  }
+
+  public String getStatusText() {
+    return internal.getStatusText();
+  }
+
+  public DateTime getLastModified() {
+    return internal.getLastModified();
+  }
+
+  public long getContentLength() {
+    return internal.getContentLength();
+  }
+
+  public String getAllow() {
+    return internal.getAllow();
+  }
+
+  public IRI getLocation() {
+    return internal.getLocation();
+  }
+
+  public long getAge() {
+    return internal.getAge();
+  }
+
+  public DateTime getExpires() {
+    return internal.getExpires();
+  }
+
+  public String getHeader(String name) {
+    return internal.getHeader(name);
+  }
+
+  public String getDecodedHeader(String name) {
+    return internal.getDecodedHeader(name);
+  }
+
+  public Iterable<Object> getHeaders(String name) {
+    return internal.getHeaders(name);
+  }
+
+  public Iterable<String> getDecodedHeaders(String name) {
+    return internal.getDecodedHeaders(name);
+  }
+
+  public Iterable<String> getHeaderNames() {
+    return internal.getHeaderNames();
+  }
+
+  public String getSlug() {
+    return internal.getSlug();
+  }
+
+  public MimeType getContentType() {
+    return internal.getContentType();
+  }
+
+  public IRI getContentLocation() {
+    return internal.getContentLocation();
+  }
+
+  public String getContentLanguage() {
+    return internal.getContentLanguage();
+  }
+
+  public DateTime getDateHeader(String name) {
+    return internal.getDateHeader(name);
+  }
+
+  public CacheControl getCacheControl() {
+    return internal.getCacheControl();
+  }
+
+  public Iterable<Authentication> getAuthentication() {
+    return internal.getAuthentication();
+  }
+
+  public Iterable<WebLink> getWebLinks() {
+    return internal.getWebLinks();
+  }
+
+  public Iterable<Preference> getPrefer() {
+    return internal.getPrefer();
+  }
+
+  public Method getMethod() {
+    return internal.getMethod();
+  }
+
+  public String getUri() {
+    return internal.getUri();
+  }
+
+  public void release() {
+    internal.release();
+  }
+
+  public InputStream getInputStream() throws IOException {
+    return internal.getInputStream();
+  }
+
+  public Reader getReader() throws IOException {
+    return internal.getReader();
+  }
+
+  public Reader getReader(String charset) throws IOException {
+    return internal.getReader(charset);
+  }
+
+  public DateTime getServerDate() {
+    return internal.getServerDate();
+  }
+
+  public String getCharacterEncoding() {
+    return internal.getCharacterEncoding();
+  }
+
+  public void writeTo(OutputStream out) throws IOException {
+    internal.writeTo(out);
+  }
+
+  public Session getSession() {
+    return internal.getSession();
+  }
+
+  public <T> T getHeader(String name, Function<String, T> transform) {
+    return internal.getHeader(name, transform);
+  }
+
+  public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+    return internal.getHeaders(name, transform);
+  }
+
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientResponseWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.net.URISyntaxException;
+import java.util.Date;
+
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.scheme.SchemeSocketFactory;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.HttpParams;
+
+@SuppressWarnings("unchecked")
+public abstract class ClientWrapper 
+  implements Client {
+
+  private final Client internal;
+  
+  protected ClientWrapper(Client client) {
+    this.internal = client;
+  }
+  
+  public <T extends Client>T  addRequestInterceptor(HttpRequestInterceptor i, int index) {
+    internal.addRequestInterceptor(i, index);
+    return (T)this;
+  }
+
+  public <T extends Client>T  addResponseInterceptor(HttpResponseInterceptor i, int index) {
+    internal.addResponseInterceptor(i,index);
+    return (T)this;
+  }
+
+  public <T extends Client>T  clearRequestInterceptors() {
+    internal.clearRequestInterceptors();
+    return (T)this;
+  }
+
+  public <T extends Client>T  clearResponseInterceptors() {
+    internal.clearResponseInterceptors();
+    return (T)this;
+  }
+
+  public <T extends Client>T  registerScheme(String scheme, int port,
+      SchemeSocketFactory factory) {
+    internal.registerScheme(scheme, port, factory);
+    return (T)this;
+  }
+
+  public HttpClient getClient() {
+    return internal.getClient();
+  }
+
+  public DefaultHttpClient getDefaultHttpClient() {
+    return internal.getDefaultHttpClient();
+  }
+
+  public <T extends Client>T addCredentials(
+    String target, String realm, String scheme, String user, 
+    String password) throws URISyntaxException {
+    internal.addCredentials(target, realm, scheme, user, password);
+    return (T)this;
+  }
+  
+  public <T extends Client>T  addCredentials(String target, String realm, String scheme,
+      Credentials credentials) throws URISyntaxException {
+    internal.addCredentials(target, realm, scheme, credentials);
+    return (T)this;
+  }
+
+  public <T extends Client>T  setAuthenticationSchemePriority(String... scheme) {
+    internal.setAuthenticationSchemePriority(scheme);
+    return (T)this;
+  }
+
+  public String[] getAuthenticationSchemePriority() {
+    return internal.getAuthenticationSchemePriority();
+  }
+
+  public <T extends Client>T  setMaxConnectionsPerHost(int max) {
+    internal.setMaxConnectionsPerHost(max);
+    return (T)this;
+  }
+
+  public int getMaxConnectionsPerHost() {
+    return internal.getMaxConnectionsPerHost();
+  }
+
+  public <T extends Client>T  setMaxConnectionsTotal(int max) {
+    internal.setMaxConnectionsTotal(max);
+    return (T)this;
+  }
+
+  public int getMaxConnectionsTotal() {
+    return internal.getMaxConnectionsTotal();
+  }
+
+  public <T extends Client>T  setProxy(String host, int port) {
+    internal.setProxy(host,port);
+    return (T)this;
+  }
+
+  public <T extends Client>T  setStandardProxy() {
+    internal.setStandardProxy();
+    return (T)this;
+  }
+
+  public CookieStore getCookieStore() {
+    return internal.getCookieStore();
+  }
+
+  public CookieStore getCookieStore(boolean create) {
+    return internal.getCookieStore(create);
+  }
+
+  public <T extends Client>T  setCookieStore(CookieStore cookieStore) {
+    internal.setCookieStore(cookieStore);
+    return (T)this;
+  }
+
+  public <T extends Client>T  addCookie(String domain, String name, String value) {
+    internal.addCookie(domain, name, value);
+    return (T)this;
+  }
+
+  public <T extends Client>T  addCookie(String domain, String name, String value,
+      String path, Date expires, boolean secure) {
+    internal.addCookie(domain, name, value, path, expires, secure);
+    return (T)this;
+  }
+
+  public <T extends Client>T  addCookies(Cookie cookie) {
+    internal.addCookies(cookie);
+    return (T)this;
+  }
+
+  public <T extends Client>T  addCookies(Cookie... cookies) {
+    internal.addCookies(cookies);
+    return (T)this;
+  }
+
+  public Iterable<Cookie> getCookies() {
+    return internal.getCookies();
+  }
+
+  public Iterable<Cookie> getCookies(String domain, String path) {
+    return internal.getCookies(domain, path);
+  }
+
+  public Iterable<Cookie> getCookies(String domain) {
+    return internal.getCookies(domain);
+  }
+
+  public <T extends Client>T  clearCookies() {
+    internal.clearCookies();
+    return (T)this;
+  }
+
+  public <T extends Client>T  clearExpiredCookies() {
+    internal.clearExpiredCookies();
+    return (T)this;
+  }
+
+  public <T extends Client>T  setConnectionTimeout(int timeout) {
+    internal.setConnectionTimeout(timeout);
+    return (T)this;
+  }
+
+  public <T extends Client>T  setSocketTimeout(int timeout) {
+    internal.setSocketTimeout(timeout);
+    return (T)this;
+  }
+
+  public int getConnectionTimeout() {
+    return internal.getConnectionTimeout();
+  }
+
+  public int getSocketTimeout() {
+    return internal.getSocketTimeout();
+  }
+
+  public void setTcpNoDelay(boolean enable) {
+    internal.setTcpNoDelay(enable);
+  }
+
+  public boolean getTcpNoDelay() {
+    return internal.getTcpNoDelay();
+  }
+
+  public HttpParams getHttpConnectionManagerParams() {
+   return internal.getHttpConnectionManagerParams();
+  }
+
+  public <T extends Client>T  setMaximumRedirects(int redirects) {
+    internal.setMaximumRedirects(redirects);
+    return (T)this;
+  }
+
+  public int getMaximumRedirects() {
+    return internal.getMaximumRedirects();
+  }
+
+  public <T extends Client>T  clearCredentials() {
+    internal.clearCredentials();
+    return (T)this;
+  }
+
+  public <T extends Session>T newSession() {
+    return (T)new Session(this);
+  }
+
+  public void shutdown() {
+    internal.shutdown();
+  }
+
+  public void includeRequestDateHeader() {
+    internal.includeRequestDateHeader();
+  }
+
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ClientWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+public class NonOpTrustManager 
+  implements X509TrustManager {
+
+    public void checkClientTrusted(
+        X509Certificate[] arg0, String arg1) 
+          throws CertificateException {}
+
+    public void checkServerTrusted(
+        X509Certificate[] arg0, 
+        String arg1) throws CertificateException {}
+
+    public X509Certificate[] getAcceptedIssuers() {
+        return null;
+    }
+
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/NonOpTrustManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java?rev=1239261&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java Wed Feb  1 18:49:11 2012
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.protocol;
+
+import java.net.URI;
+
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.Method;
+
+import static org.apache.abdera2.common.http.Method.*;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpRequest;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpTrace;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpParams;
+
+import com.google.common.collect.ImmutableSet;
+
+public final class RequestHelper {
+
+    private RequestHelper() {}
+     
+    // the set of methods we never use post-override for
+    private static final ImmutableSet<Method> nopostoveride = 
+      ImmutableSet.of(
+        Method.GET,
+        Method.POST,
+        Method.OPTIONS,
+        Method.HEAD,
+        Method.TRACE);
+    
+    public static HttpUriRequest createRequest(
+      String method, 
+      String uri, 
+      HttpEntity entity, 
+      RequestOptions options) {
+        if (method == null)
+            return null;
+        if (options == null)
+          options = createAtomDefaultRequestOptions().get();
+        Method m = Method.get(method);
+        Method actual = null;
+        HttpUriRequest httpMethod = null;
+        if (options.isUsePostOverride() && 
+            !nopostoveride.contains(m)) {
+          actual = m;
+          m = Method.POST;
+        }
+        if (m == GET)
+          httpMethod = new HttpGet(uri);
+        else if (m == POST) {
+          httpMethod = new HttpPost(uri);
+          if (entity != null) 
+            ((HttpPost)httpMethod).setEntity(entity);
+        } else if (m == PUT) {
+          httpMethod = new HttpPut(uri);
+          if (entity != null)
+            ((HttpPut)httpMethod).setEntity(entity);
+        } else if (m == DELETE)
+          httpMethod = new HttpDelete(uri);
+        else if (m == HEAD)
+          httpMethod = new HttpHead(uri);
+        else if (m == OPTIONS)
+          httpMethod = new HttpOptions(uri);
+        else if (m == TRACE)
+          httpMethod = new HttpTrace(uri);
+//        else if (m == PATCH)
+//          httpMethod = new ExtensionRequest(m.name(),uri,entity);
+        else
+          httpMethod = new ExtensionRequest(m.name(),uri,entity);
+        if (actual != null) {
+            httpMethod.addHeader("X-HTTP-Method-Override", actual.name());
+        }
+        initHeaders(options, httpMethod);
+        HttpParams params = httpMethod.getParams();
+        if (!options.isUseExpectContinue()) {
+          params.setBooleanParameter(
+            CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
+        } else {
+          if (options.getWaitForContinue() > -1)
+            params.setIntParameter(
+              CoreProtocolPNames.WAIT_FOR_CONTINUE, 
+              options.getWaitForContinue());
+        }
+        if (!(httpMethod instanceof HttpEntityEnclosingRequest))
+            params.setBooleanParameter(
+              ClientPNames.HANDLE_REDIRECTS, 
+              options.isFollowRedirects()); 
+        return httpMethod;
+    }
+
+    private static void initHeaders(RequestOptions options, HttpRequest request) {
+        Iterable<String> headers = options.getHeaderNames();
+        for (String header : headers) {
+            Iterable<Object> values = options.getHeaders(header);
+            for (Object value : values)
+                request.addHeader(header, value.toString());
+        }
+        CacheControl cc = options.getCacheControl();
+        if (cc != null) { 
+            String scc = cc.toString();
+            if (scc.length() > 0)
+              request.setHeader("Cache-Control", scc);
+        }
+// TODO: Authentication setup per request???
+//        if (options.getAuthorization() != null)
+//            method.setDoAuthentication(false);
+    }
+
+    public static class ExtensionRequest 
+      extends HttpEntityEnclosingRequestBase {
+      private final String method;
+      public ExtensionRequest(String method, String uri, HttpEntity entity) {
+        try {
+          super.setURI(new URI(uri));
+        } catch (Throwable t) {
+          throw new IllegalArgumentException(t);
+        }
+        this.method = method;
+        if (entity != null)
+          setEntity(entity);
+      }
+      public String getMethod() {
+        return method;
+      }
+      
+    }
+    
+    public static RequestOptions.Builder createAtomDefaultRequestOptions() {
+      return RequestOptions.make()
+        .acceptEncoding("gzip", "deflate")
+        .accept(
+          "application/atom+xml;type=entry",
+          "application/atom+xml;type=feed",
+          "application/atom+xml",
+          "application/atomsvc+xml",
+          "application/atomcat+xml",
+          "application/xml;q=0.5",
+          "text/xml;q=0.5",
+          "*/*;q=0.01")
+        .acceptCharset("utf-8", "*;q=0.5");
+    }
+    
+    public static RequestOptions.Builder createActivitiesDefaultRequestOptions() {
+      return RequestOptions.make()
+        .acceptEncoding("gzip", "deflate")
+        .accept(
+          "application/json",
+          "*/*;q=0.01")
+        .acceptCharset(
+          "utf-8", 
+          "*;q=0.5");
+    }
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message