hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1189320 - in /httpcomponents/httpclient/trunk/fluent-hc/src: main/java/org/apache/http/client/fluent/ main/java/org/apache/http/client/fluent/header/ test/java/org/apache/http/client/fluent/
Date Wed, 26 Oct 2011 17:11:42 GMT
Author: olegk
Date: Wed Oct 26 17:11:41 2011
New Revision: 1189320

URL: http://svn.apache.org/viewvc?rev=1189320&view=rev
Log:
Rewrite of the fluent API

Added:
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java   (contents, props changed)
      - copied, changed from r1182515, httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentHttpMethod.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java   (contents, props changed)
      - copied, changed from r1182515, httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/HttpHeader.java
Removed:
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentHttpMethod.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/CacheControl.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/ContentType.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/DateUtils.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/HttpHeader.java
    httpcomponents/httpclient/trunk/fluent-hc/src/test/java/org/apache/http/client/fluent/TestFluentRequest.java
Modified:
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentExecutor.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentRequest.java
    httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentResponse.java

Copied: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java (from r1182515, httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentHttpMethod.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java?p2=httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java&p1=httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentHttpMethod.java&r1=1182515&r2=1189320&rev=1189320&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentHttpMethod.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java Wed Oct 26 17:11:41 2011
@@ -26,6 +26,46 @@
 
 package org.apache.http.client.fluent;
 
-public enum FluentHttpMethod {
-    GET_METHOD, POST_METHOD, DELETE_METHOD, OPTIONS_METHOD, PUT_METHOD, HEAD_METHOD, TRACE_METHOD;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.http.entity.ContentType;
+import org.apache.http.protocol.HTTP;
+
+public class Content {
+
+    private final byte[] raw;
+    private final ContentType type;
+
+    Content(final byte[] raw, final ContentType type) {
+        super();
+        this.raw = raw;
+        this.type = type;
+    }
+
+    public ContentType getType() {
+        return this.type;
+    }
+
+    public byte[] asBytes() {
+        return this.raw.clone();
+    }
+
+    public String asString() {
+        String charset = this.type.getCharset();
+        if (charset == null) {
+            charset = HTTP.DEFAULT_CONTENT_TYPE;
+        }
+        try {
+            return new String(this.raw, charset);
+        } catch (UnsupportedEncodingException ex) {
+            return new String(this.raw);
+        }
+    }
+
+    public InputStream asStream() {
+        return new ByteArrayInputStream(this.raw);
+    }
+
 }

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentExecutor.java?rev=1189320&r1=1189319&r2=1189320&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentExecutor.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentExecutor.java Wed Oct 26 17:11:41 2011
@@ -27,142 +27,150 @@
 package org.apache.http.client.fluent;
 
 import java.io.IOException;
-import java.util.List;
 
-import org.apache.http.HttpResponse;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.NTCredentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
 import org.apache.http.client.ClientProtocolException;
-import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.conn.routing.HttpRoute;
 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.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.http.impl.conn.SchemeRegistryFactory;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.protocol.BasicHttpContext;
 
 public class FluentExecutor {
 
+    final static PoolingClientConnectionManager CONNMGR = new PoolingClientConnectionManager(
+            SchemeRegistryFactory.createSystemDefault());
+    final static DefaultHttpClient CLIENT = new DefaultHttpClient(CONNMGR);
+
     public static FluentExecutor newInstance() {
-        FluentExecutor fexe = new FluentExecutor();
-        return fexe;
+        return new FluentExecutor(CLIENT);
     }
 
-    private ThreadSafeClientConnManager localConnManager;
-    private SchemeRegistry localSchemeRegistry;
-    private SchemeSocketFactory localSocketFactory;
-
-    private FluentExecutor() {
-        localSchemeRegistry = SchemeRegistryFactory.createDefault();
-        localConnManager = new ThreadSafeClientConnManager(localSchemeRegistry);
-        localSocketFactory = PlainSocketFactory.getSocketFactory();
+    private final HttpClient httpclient;
+    private final BasicHttpContext localContext;
+    private final AuthCache authCache;
+
+    private CredentialsProvider credentialsProvider;
+    private CookieStore cookieStore;
 
+    FluentExecutor(final HttpClient httpclient) {
+        super();
+        this.httpclient = httpclient;
+        this.localContext = new BasicHttpContext();
+        this.authCache = new BasicAuthCache();
     }
 
-    public FluentResponse exec(FluentRequest req)
-            throws ClientProtocolException, IOException {
-        DefaultHttpClient client = getClient();
-        client.setCredentialsProvider(req.getCredentialsProvider());
-        client.setParams(req.getLocalParams());
-        HttpResponse resp = client.execute(req, req.getLocalContext());
-        FluentResponse fresp = new FluentResponse(resp);
-        return fresp;
-    }
-
-    public FluentResponse[] exec(final FluentRequest[] reqs)
-            throws InterruptedException {
-        if (reqs == null)
-            throw new NullPointerException("The request array may not be null.");
-        int length = reqs.length;
-        if (length == 0)
-            return new FluentResponse[0];
-        FluentResponse[] resps = new FluentResponse[length];
-        MultiRequestThread[] threads = new MultiRequestThread[length];
-        for (int id = 0; id < length; id++) {
-            threads[id] = new MultiRequestThread(this, reqs, resps, id);
-        }
-        for (int id = 0; id < length; id++) {
-            threads[id].start();
+    public FluentExecutor auth(final AuthScope authScope, final Credentials creds) {
+        if (this.credentialsProvider == null) {
+            this.credentialsProvider = new BasicCredentialsProvider();
         }
-        for (int id = 0; id < length; id++) {
-            threads[id].join();
-        }
-        return resps;
+        this.credentialsProvider.setCredentials(authScope, creds);
+        return this;
     }
 
-    public DefaultHttpClient getClient() {
-        DefaultHttpClient client;
-        client = new DefaultHttpClient(localConnManager);
-        return client;
+    public FluentExecutor auth(final HttpHost host, final Credentials creds) {
+        AuthScope authScope = host != null ? new AuthScope(host) : AuthScope.ANY;
+        return auth(authScope, creds);
     }
 
-    public int getMaxConnectionsPerRoute() {
-        return localConnManager.getDefaultMaxPerRoute();
+    public FluentExecutor authPreemptive(final HttpHost host, final Credentials creds) {
+        auth(host, creds);
+        this.authCache.put(host, new BasicScheme());
+        return this;
     }
 
-    public int getMaxTotalConnections() {
-        return localConnManager.getMaxTotal();
+    public FluentExecutor auth(final Credentials cred) {
+        return auth(AuthScope.ANY, cred);
     }
 
-    public Scheme getScheme(final String name) {
-        return localSchemeRegistry.getScheme(name);
+    public FluentExecutor auth(final String username, final String password) {
+        return auth(new UsernamePasswordCredentials(username, password));
     }
 
-    public List<String> getSchemeNames() {
-        List<String> schemeNames = localSchemeRegistry.getSchemeNames();
-        return schemeNames;
+    public FluentExecutor auth(final String username, final String password,
+            final String workstation, final String domain) {
+        return auth(new NTCredentials(username, password, workstation, domain));
     }
 
-    public FluentExecutor registerScheme(final String name, final int port) {
-        Scheme sch = new Scheme(name, port, localSocketFactory);
-        localSchemeRegistry.register(sch);
-        return this;
+    public FluentExecutor auth(final HttpHost host,
+            final String username, final String password) {
+        return auth(host, new UsernamePasswordCredentials(username, password));
     }
 
-    public FluentExecutor setMaxConnectionsPerRoute(final int maxPerRoute) {
-        localConnManager.setDefaultMaxPerRoute(maxPerRoute);
-        return this;
+    public FluentExecutor auth(final HttpHost host,
+            final String username, final String password,
+            final String workstation, final String domain) {
+        return auth(host, new NTCredentials(username, password, workstation, domain));
     }
 
-    public FluentExecutor setMaxTotalConnections(final int maxTotal) {
-        localConnManager.setMaxTotal(maxTotal);
+    public FluentExecutor authPreemptive(final HttpHost host,
+            final String username, final String password) {
+        auth(host, username, password);
+        this.authCache.put(host, new BasicScheme());
         return this;
     }
 
-    public FluentExecutor unregisterAllSchemes() {
-        for (String name : getSchemeNames())
-            localSchemeRegistry.unregister(name);
+    public FluentExecutor clearAuth() {
+        if (this.credentialsProvider != null) {
+            this.credentialsProvider.clear();
+        }
         return this;
     }
 
-    public FluentExecutor unregisterScheme(final String name) {
-        localSchemeRegistry.unregister(name);
+    public FluentExecutor cookieStore(final CookieStore cookieStore) {
+        this.cookieStore = cookieStore;
         return this;
     }
-}
 
-class MultiRequestThread extends Thread {
-    private FluentExecutor executor;
-    private FluentRequest[] reqs;
-    private FluentResponse[] resps;
-    private int id;
-
-    MultiRequestThread(final FluentExecutor executor,
-            final FluentRequest[] reqs, final FluentResponse[] resps,
-            final int id) {
-        this.executor = executor;
-        this.reqs = reqs;
-        this.resps = resps;
-        this.id = id;
-    }
-
-    @Override
-    public void run() {
-        FluentRequest req = reqs[id];
-        try {
-            FluentResponse resp = executor.exec(req);
-            resp.loadContent();
-            resps[id] = resp;
-        } catch (Exception e) {
-            req.abort();
+    public FluentExecutor clearCookies() {
+        if (this.cookieStore != null) {
+            this.cookieStore.clear();
         }
+        return this;
+    }
+
+    public FluentResponse exec(
+            final FluentRequest req) throws ClientProtocolException, IOException {
+        this.localContext.setAttribute(ClientContext.CREDS_PROVIDER, this.credentialsProvider);
+        this.localContext.setAttribute(ClientContext.AUTH_CACHE, this.authCache);
+        this.localContext.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
+        HttpRequestBase httprequest = req.getHttpRequest();
+        httprequest.reset();
+        return new FluentResponse(this.httpclient.execute(httprequest, this.localContext));
+    }
+
+    public static void setMaxTotal(int max) {
+        CONNMGR.setMaxTotal(max);
+    }
+
+    public static void setDefaultMaxPerRoute(int max) {
+        CONNMGR.setDefaultMaxPerRoute(max);
+    }
+
+    public static void setMaxPerRoute(final HttpRoute route, int max) {
+        CONNMGR.setMaxPerRoute(route, max);
+    }
+
+    public static void registerScheme(final Scheme scheme) {
+        CONNMGR.getSchemeRegistry().register(scheme);
     }
+
+    public static void unregisterScheme(final String name) {
+        CONNMGR.getSchemeRegistry().unregister(name);
+    }
+
 }

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentRequest.java?rev=1189320&r1=1189319&r2=1189320&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentRequest.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentRequest.java Wed Oct 26 17:11:41 2011
@@ -27,524 +27,277 @@
 package org.apache.http.client.fluent;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.Locale;
+import java.util.TimeZone;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
 import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpVersion;
 import org.apache.http.NameValuePair;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
 import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.fluent.header.DateUtils;
-import org.apache.http.client.fluent.header.HttpHeader;
 import org.apache.http.client.methods.HttpDelete;
 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.HttpRequestBase;
 import org.apache.http.client.methods.HttpTrace;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.conn.params.ConnRoutePNames;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HTTP;
 
-public class FluentRequest implements HttpUriRequest {
-    private HttpParams localParams;
-    private HttpContext localContext;
-    private CredentialsProvider credentialsProvider;
-    private HttpUriRequest request;
-    private FluentHttpMethod method;
-    private HttpHost localProxy;
-
-    protected static final Log log = LogFactory.getLog(FluentRequest.class);
-
-    public FluentRequest(final HttpUriRequest req) {
-        URI uri = req.getURI();
-        String methodName = req.getMethod().toUpperCase();
-        FluentHttpMethod method = FluentHttpMethod.GET_METHOD;
-        if (methodName.equals("GET"))
-            method = FluentHttpMethod.GET_METHOD;
-        else if (methodName.equals("POST"))
-            method = FluentHttpMethod.POST_METHOD;
-        else if (methodName.equals("OPTIONS"))
-            method = FluentHttpMethod.OPTIONS_METHOD;
-        else if (methodName.equals("DELETE"))
-            method = FluentHttpMethod.DELETE_METHOD;
-        else if (methodName.equals("HEAD"))
-            method = FluentHttpMethod.HEAD_METHOD;
-        else if (methodName.equals("PUT"))
-            method = FluentHttpMethod.PUT_METHOD;
-        else if (methodName.equals("TRACE"))
-            method = FluentHttpMethod.TRACE_METHOD;
-        init(uri, method);
-    }
-
-    public FluentRequest(final String uri) {
-        init(uri, FluentHttpMethod.GET_METHOD);
-    }
-
-    public FluentRequest(final String uri, final FluentHttpMethod method) {
-        init(uri, method);
-    }
+public class FluentRequest {
 
-    public FluentRequest(final URI uri) {
-        init(uri, FluentHttpMethod.GET_METHOD);
-    }
+    public static final String DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
+    public static final Locale DATE_LOCALE = Locale.US;
+    public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT");
 
-    public FluentRequest(final URI uri, final FluentHttpMethod method) {
-        init(uri, method);
-    }
+    private final HttpRequestBase request;
+    private final HttpParams localParams;
 
-    public void abort() throws UnsupportedOperationException {
-        this.request.abort();
-    }
+    private SimpleDateFormat dateFormatter;
 
-    public void addHeader(final Header header) {
-        this.request.addHeader(header);
+    public static FluentRequest Get(final URI uri) {
+        return new FluentRequest(new HttpGet(uri));
     }
 
-    public void addHeader(final String name, final String value) {
-        this.request.addHeader(name, value);
-    }
-
-    public boolean containsHeader(final String name) {
-        return this.request.containsHeader(name);
+    public static FluentRequest Get(final String uri) {
+        return new FluentRequest(new HttpGet(uri));
     }
 
-    /**
-     *
-     * @return a <code>FluentResponse</code> instance referring to the response
-     *         of this request
-     * @throws ClientProtocolException
-     * @throws IOException
-     */
-    public FluentResponse exec() throws ClientProtocolException, IOException {
-        DefaultHttpClient client = new DefaultHttpClient();
-        return new FluentResponse(client.execute(request));
+    public static FluentRequest Head(final URI uri) {
+        return new FluentRequest(new HttpHead(uri));
     }
 
-    public Header[] getAllHeaders() {
-        return this.request.getAllHeaders();
+    public static FluentRequest Head(final String uri) {
+        return new FluentRequest(new HttpHead(uri));
     }
 
-    public String getCacheControl() {
-        return getValueOfHeader(HttpHeader.CACHE_CONTROL);
+    public static FluentRequest Post(final URI uri) {
+        return new FluentRequest(new HttpPost(uri));
     }
 
-    public int getConnectionTimeout() {
-        return HttpConnectionParams.getConnectionTimeout(localParams);
+    public static FluentRequest Post(final String uri) {
+        return new FluentRequest(new HttpPost(uri));
     }
 
-    public String getContentCharset() {
-        return (String) localParams
-                .getParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET);
+    public static FluentRequest Put(final URI uri) {
+        return new FluentRequest(new HttpPut(uri));
     }
 
-    public long getContentLength() {
-        String value = getValueOfHeader(HttpHeader.CONTENT_LENGTH);
-        if (value == null)
-            return -1;
-        else {
-            long contentLength = Long.parseLong(value);
-            return contentLength;
-        }
+    public static FluentRequest Put(final String uri) {
+        return new FluentRequest(new HttpPut(uri));
     }
 
-    public String getContentType() {
-        return getValueOfHeader(HttpHeader.CONTENT_TYPE);
+    public static FluentRequest Trace(final URI uri) {
+        return new FluentRequest(new HttpTrace(uri));
     }
 
-    public CredentialsProvider getCredentialsProvider() {
-        return credentialsProvider;
+    public static FluentRequest Trace(final String uri) {
+        return new FluentRequest(new HttpTrace(uri));
     }
 
-    public String getDate() {
-        return getValueOfHeader(HttpHeader.DATE);
+    public static FluentRequest Delete(final URI uri) {
+        return new FluentRequest(new HttpDelete(uri));
     }
 
-    public String getElementCharset() {
-        return (String) localParams
-                .getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
+    public static FluentRequest Delete(final String uri) {
+        return new FluentRequest(new HttpDelete(uri));
     }
 
-    public Header getFirstHeader(final String name) {
-        return this.request.getFirstHeader(name);
+    public static FluentRequest Options(final URI uri) {
+        return new FluentRequest(new HttpOptions(uri));
     }
 
-    public Header[] getHeaders(final String name) {
-        return this.request.getHeaders(name);
+    public static FluentRequest Options(final String uri) {
+        return new FluentRequest(new HttpOptions(uri));
     }
 
-    /**
-     * Returns the HTTP method as a field of <code><a
-     * href="FunHttpMethod.html">FunHttpMethod</a></code> enumeration, such as
-     * <code>GET</code>, <code>PUT</code>, <code>POST</code>, or other.
-     *
-     * @return a field of <a href="FunHttpMethod.html">FunHttpMethod</a>
-     *         enumeration indicates the name of HTTP method
-     */
-    public FluentHttpMethod getHttpMethod() {
-        return method;
+    FluentRequest(final HttpRequestBase request) {
+        super();
+        this.request = request;
+        this.localParams = request.getParams();
     }
 
-    public HttpVersion getHttpVersion() {
-        return (HttpVersion) this.localParams
-                .getParameter(CoreProtocolPNames.PROTOCOL_VERSION);
+    HttpRequestBase getHttpRequest() {
+        return this.request;
     }
 
-    public String getIfModifiedSince() {
-        return getValueOfHeader(HttpHeader.IF_MODIFIED_SINCE);
-    }
-
-    public String getIfUnmodifiedSince() {
-        return getValueOfHeader(HttpHeader.IF_UNMODIFIED_SINCE);
-    }
-
-    public Header getLastHeader(final String name) {
-        return this.request.getLastHeader(name);
-    }
-
-    public HttpContext getLocalContext() {
-        return localContext;
-    }
-
-    public HttpParams getLocalParams() {
-        return localParams;
-    }
-
-    public String getMethod() {
-        return this.request.getMethod();
-    }
-
-    public HttpParams getParams() {
-        return this.request.getParams();
-    }
-
-    public ProtocolVersion getProtocolVersion() {
-        return this.request.getProtocolVersion();
-    }
-
-    public RequestLine getRequestLine() {
-        return this.request.getRequestLine();
-    }
-
-    public int getSocketTimeout() {
-        return HttpConnectionParams.getSoTimeout(localParams);
-    }
-
-    public URI getURI() {
-        return this.request.getURI();
-    }
-
-    public String getUserAgent() {
-        return (String) localParams.getParameter(CoreProtocolPNames.USER_AGENT);
-    }
-
-    private String getValueOfHeader(final String headerName) {
-        Header header = request.getFirstHeader(headerName);
-        if (header != null)
-            return header.getValue();
-        else
-            return null;
-    }
-
-    public int getWaitForContinue() {
-        return (Integer) localParams
-                .getParameter(CoreProtocolPNames.WAIT_FOR_CONTINUE);
-    }
-
-    public HeaderIterator headerIterator() {
-        return this.request.headerIterator();
-    }
-
-    public HeaderIterator headerIterator(final String name) {
-        return this.request.headerIterator(name);
-    }
-
-    private void init(final String uriString, final FluentHttpMethod method) {
-        try {
-            URI uri = new URI(uriString);
-            init(uri, method);
-        } catch (URISyntaxException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    private void init(final URI uri, final FluentHttpMethod method) {
-        switch (method) {
-        case GET_METHOD:
-            this.request = new HttpGet(uri);
-            break;
-        case POST_METHOD:
-            this.request = new HttpPost(uri);
-            break;
-        case OPTIONS_METHOD:
-            this.request = new HttpOptions(uri);
-            break;
-        case DELETE_METHOD:
-            this.request = new HttpDelete(uri);
-            break;
-        case HEAD_METHOD:
-            this.request = new HttpHead(uri);
-            break;
-        case PUT_METHOD:
-            this.request = new HttpPut(uri);
-            break;
-        case TRACE_METHOD:
-            this.request = new HttpTrace(uri);
-            break;
-        }
-        this.method = method;
-        localParams = request.getParams();
-        localContext = new BasicHttpContext();
-        credentialsProvider = new BasicCredentialsProvider();
-        localProxy = null;
+    public FluentResponse exec() throws ClientProtocolException, IOException {
+        return new FluentResponse(FluentExecutor.CLIENT.execute(this.request));
     }
 
-    public boolean isAborted() {
-        return this.request.isAborted();
+    public void abort() throws UnsupportedOperationException {
+        this.request.abort();
     }
 
-    public boolean isStrictTransferEncoding() {
-        return (Boolean) localParams
-                .getParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING);
-    }
+    //// HTTP header operations
 
-    public boolean isUseExpectContinue() {
-        return (Boolean) localParams
-                .getParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE);
+    public FluentRequest addHeader(final Header header) {
+        this.request.addHeader(header);
+        return this;
     }
 
-    public FluentRequest removeAuth() {
-        return setAuth(null);
+    public FluentRequest addHeader(final String name, final String value) {
+        this.request.addHeader(name, value);
+        return this;
     }
 
-    public void removeHeader(final Header header) {
+    public FluentRequest removeHeader(final Header header) {
         this.request.removeHeader(header);
+        return this;
     }
 
-    public void removeHeaders(final String name) {
+    public FluentRequest removeHeaders(final String name) {
         this.request.removeHeaders(name);
-    }
-
-    public FluentRequest removeProxy() {
-        setProxyAuth(null);
-        localParams.removeParameter(ConnRoutePNames.DEFAULT_PROXY);
-        localProxy = null;
         return this;
     }
 
-    public FluentRequest setAuth(final Credentials cred) {
-        String hostAddr = request.getURI().getHost();
-        credentialsProvider.setCredentials(new AuthScope(hostAddr,
-                AuthScope.ANY_PORT), cred);
-        AuthCache authCache = new BasicAuthCache();
-        HttpHost authHost = new HttpHost(hostAddr);
-        authCache.put(authHost, new BasicScheme());
-        localContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
+    public FluentRequest setHeaders(final Header[] headers) {
+        this.request.setHeaders(headers);
         return this;
     }
 
-    public FluentRequest setAuth(final String username, final String password) {
-        return setAuth(new UsernamePasswordCredentials(username, password));
-    }
-
-    public FluentRequest setAuth(final String username, final String password,
-            final String workstation, final String domain) {
-        return setAuth(new NTCredentials(username, password, workstation,
-                domain));
-    }
-
     public FluentRequest setCacheControl(String cacheControl) {
-        request.setHeader(HttpHeader.CACHE_CONTROL, cacheControl);
+        this.request.setHeader(HttpHeader.CACHE_CONTROL, cacheControl);
         return this;
     }
 
-    public FluentRequest setConnectionTimeout(final int connectionTimeoutMillis) {
-        HttpConnectionParams.setConnectionTimeout(localParams,
-                connectionTimeoutMillis);
-        return this;
+    private SimpleDateFormat getDateFormat() {
+        if (this.dateFormatter == null) {
+            this.dateFormatter = new SimpleDateFormat(DATE_FORMAT, DATE_LOCALE);
+            this.dateFormatter.setTimeZone(TIME_ZONE);
+        }
+        return this.dateFormatter;
     }
 
-    public FluentRequest setContentCharset(final String charset) {
-        localParams.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,
-                charset);
+    public FluentRequest setDate(final Date date) {
+        this.request.setHeader(HttpHeader.DATE, getDateFormat().format(date));
         return this;
     }
 
-    public FluentRequest setContentLength(final long contentLength) {
-        request.setHeader(HttpHeader.CONTENT_LENGTH,
-                String.valueOf(contentLength));
+    public FluentRequest setIfModifiedSince(final Date date) {
+        this.request.setHeader(HttpHeader.IF_MODIFIED_SINCE, getDateFormat().format(date));
         return this;
     }
 
-    public FluentRequest setContentType(final String contentType) {
-        request.setHeader(HttpHeader.CONTENT_TYPE, contentType);
+    public FluentRequest setIfUnmodifiedSince(final Date date) {
+        this.request.setHeader(HttpHeader.IF_UNMODIFIED_SINCE, getDateFormat().format(date));
         return this;
     }
 
-    public FluentRequest setCredentialProvider(
-            final CredentialsProvider credProvider) {
-        credentialsProvider = credProvider;
-        return this;
-    }
+    //// HTTP config parameter operations
 
-    public FluentRequest setDate(final Date date) {
-        String formattedDate = DateUtils.format(date);
-        request.setHeader(HttpHeader.DATE, formattedDate);
+    public FluentRequest config(final String param, final Object object) {
+        this.localParams.setParameter(param, object);
         return this;
     }
 
-    public FluentRequest setElementCharset(final String charset) {
-        localParams.setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,
-                charset);
+    public FluentRequest removeConfig(final String param) {
+        this.localParams.removeParameter(param);
         return this;
     }
 
-    public FluentRequest setEntity(final HttpEntity entity) {
-        if (method == FluentHttpMethod.POST_METHOD) {
-            HttpPost post = (HttpPost) this.request;
-            post.setEntity(entity);
-        } else {
-            throw new IllegalStateException(
-                    "Only POST method can have an entity.");
-        }
-        return this;
-    }
+    //// HTTP protocol parameter operations
 
-    public void setHeader(final Header header) {
-        this.request.setHeader(header);
+    public FluentRequest version(final HttpVersion version) {
+        return config(CoreProtocolPNames.PROTOCOL_VERSION, version);
     }
 
-    public void setHeader(final String name, final String value) {
-        this.request.setHeader(name, value);
+    public FluentRequest elementCharset(final String charset) {
+        return config(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, charset);
     }
 
-    public void setHeaders(final Header[] headers) {
-        this.request.setHeaders(headers);
+    public FluentRequest useExpectContinue() {
+        return config(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
     }
 
-    public FluentRequest setHTMLFormEntity(final Map<String, String> form,
-            final String encoding) throws UnsupportedEncodingException {
-        List<NameValuePair> formparams = new ArrayList<NameValuePair>(
-                form.size());
-        for (String name : form.keySet()) {
-            formparams.add(new BasicNameValuePair(name, form.get("name")));
-        }
-        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams,
-                encoding);
-        return setEntity(entity);
+    public FluentRequest userAgent(final String agent) {
+        return config(CoreProtocolPNames.USER_AGENT, agent);
     }
 
-    public FluentRequest setHttpVersion(HttpVersion version) {
-        localParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, version);
-        return this;
-    }
+    //// HTTP connection parameter operations
 
-    public FluentRequest setIfModifiedSince(final Date date) {
-        String formattedDate = DateUtils.format(date);
-        request.setHeader(HttpHeader.IF_MODIFIED_SINCE, formattedDate);
-        return this;
+    public FluentRequest socketTimeout(int timeout) {
+        return config(CoreConnectionPNames.SO_TIMEOUT, timeout);
     }
 
-    public FluentRequest setIfUnmodifiedSince(final Date date) {
-        String formattedDate = DateUtils.format(date);
-        request.setHeader(HttpHeader.IF_UNMODIFIED_SINCE, formattedDate);
-        return this;
+    public FluentRequest connectTimeout(int timeout) {
+        return config(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
     }
 
-    public void setParams(final HttpParams params) {
-        this.request.setParams(params);
+    public FluentRequest staleConnectionCheck(boolean b) {
+        return config(CoreConnectionPNames.STALE_CONNECTION_CHECK, b);
     }
 
-    public FluentRequest setProxy(final String proxyAddr, final int proxyPort) {
-        return setProxy(proxyAddr, proxyPort, null, null);
+    //// HTTP connection route operations
+
+    public FluentRequest proxy(final HttpHost proxy) {
+        return config(ConnRoutePNames.DEFAULT_PROXY, proxy);
     }
 
-    public FluentRequest setProxy(final String proxyAddr, final int proxyPort,
-            final String username, final String password) {
-        localProxy = new HttpHost(proxyAddr, proxyPort);
-        localParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, localProxy);
-        if (username != null) {
-            setProxyAuth(username, password);
-        }
-        return this;
+    public FluentRequest noProxy() {
+        return removeConfig(ConnRoutePNames.DEFAULT_PROXY);
     }
 
-    public FluentRequest setProxyAuth(final Credentials proxyAuth) {
-        if (localProxy == null)
-            throw new IllegalStateException("HTTP proxy is not used.");
-        credentialsProvider.setCredentials(
-                new AuthScope(localProxy.getHostName(), localProxy.getPort()),
-                proxyAuth);
+    //// HTTP entity operations
+
+    public FluentRequest body(final HttpEntity entity) {
+        if (this.request instanceof HttpEntityEnclosingRequest) {
+            ((HttpEntityEnclosingRequest) this.request).setEntity(entity);
+        } else {
+            throw new IllegalStateException(this.request.getMethod()
+                    + " request cannot enclose an entity");
+        }
         return this;
     }
 
-    public FluentRequest setProxyAuth(final String username,
-            final String password) {
-        return setProxyAuth(new UsernamePasswordCredentials(username, password));
+    public FluentRequest htmlFormBody(final NameValuePair[] formParams, final String charset) {
+        try {
+            return body(new UrlEncodedFormEntity(Arrays.asList(formParams)));
+        } catch (UnsupportedEncodingException ex) {
+            throw new IllegalArgumentException(ex);
+        }
     }
 
-    public FluentRequest setProxyAuth(final String username,
-            final String password, final String workstation, final String domain) {
-        return setProxyAuth(new NTCredentials(username, password, workstation,
-                domain));
+    public FluentRequest htmlFormBody(final NameValuePair... formParams) {
+        return htmlFormBody(formParams, HTTP.DEFAULT_CONTENT_CHARSET);
     }
 
-    public FluentRequest setSocketTimeout(int socketTimeoutMillis) {
-        HttpConnectionParams.setSoTimeout(localParams, socketTimeoutMillis);
-        return this;
+    public FluentRequest stringBody(final String s, final ContentType contentType) {
+        return body(StringEntity.create(s, contentType));
     }
 
-    public FluentRequest setStrictTransferEncoding(final boolean bool) {
-        localParams.setBooleanParameter(
-                CoreProtocolPNames.STRICT_TRANSFER_ENCODING, bool);
-        return this;
+    public FluentRequest byteArrayBody(final byte[] b) {
+        return body(new ByteArrayEntity(b));
     }
 
-    public FluentRequest setUseExpectContinue(Boolean bool) {
-        localParams.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE,
-                bool);
-        return this;
+    public FluentRequest byteArrayBody(final byte[] b, int off, int len) {
+        return body(new ByteArrayEntity(b, off, len));
     }
 
-    public FluentRequest setUserAgent(final String agent) {
-        localParams.setParameter(CoreProtocolPNames.USER_AGENT, agent);
-        return this;
+    public FluentRequest streamBody(final InputStream instream) {
+        return body(new InputStreamEntity(instream, -1));
     }
 
-    public FluentRequest setWaitForContinue(final int waitMillis) {
-        localParams.setIntParameter(CoreProtocolPNames.WAIT_FOR_CONTINUE,
-                waitMillis);
-        return this;
+    public FluentRequest streamBody(final InputStream instream, final ContentType contentType) {
+        return body(new InputStreamEntity(instream, -1, contentType));
     }
 
 }

Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentResponse.java?rev=1189320&r1=1189319&r2=1189320&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentResponse.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/FluentResponse.java Wed Oct 26 17:11:41 2011
@@ -26,238 +26,105 @@
 
 package org.apache.http.client.fluent;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
 import org.apache.http.StatusLine;
-import org.apache.http.client.fluent.header.HttpHeader;
-import org.apache.http.params.HttpParams;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
 import org.apache.http.util.EntityUtils;
 
-public class FluentResponse implements HttpResponse {
-    protected static final Log log = LogFactory.getLog(FluentResponse.class);
-    private HttpResponse response;
-    private byte[] content;
-    private String contentString;
+public class FluentResponse {
+
+    private final HttpResponse response;
     private boolean consumed;
 
-    FluentResponse(HttpResponse response) {
+    FluentResponse(final HttpResponse response) {
+        super();
         this.response = response;
-        consumed = false;
-    }
-
-    public void addHeader(Header header) {
-        this.response.addHeader(header);
-    }
-
-    public void addHeader(String name, String value) {
-        this.response.addHeader(name, value);
-    }
-
-    public FluentResponse cacheControl(String cacheControl) {
-        response.setHeader(HttpHeader.CACHE_CONTROL, cacheControl);
-        return this;
-    }
-
-    public boolean containsHeader(String name) {
-        return this.response.containsHeader(name);
-    }
-
-    public Header[] getAllHeaders() {
-        return this.response.getAllHeaders();
-    }
-
-    public String getCacheControl() {
-        return getValueOfHeader(HttpHeader.CACHE_CONTROL);
-    }
-
-    public InputStream getContent() throws IllegalStateException, IOException {
-        return this.response.getEntity().getContent();
-    }
-
-    public byte[] getContentByteArray() throws IllegalStateException,
-            IOException {
-        if (!consumed)
-            loadContent();
-        return content;
-    }
-
-    public String getContentCharset() {
-        return EntityUtils.getContentCharSet(getEntity());
     }
 
-    public String getContentEncoding() {
-        if (this.getEntity() == null)
-            throw new IllegalStateException("Response does not contain data");
-        Header contentEncoding = this.getEntity().getContentEncoding();
-        if (contentEncoding == null) {
-            log.warn("Response does not contain Content-Encoding header");
-            return System.getProperty("file.encoding");
-        } else
-            return contentEncoding.getValue();
-    }
-
-    public long getContentLength() {
-        String value = getValueOfHeader(HttpHeader.CONTENT_LENGTH);
-        if (value == null)
-            return -1;
-        else {
-            long contentLength = Long.parseLong(value);
-            return contentLength;
+    private void assertNotConsumed() {
+        if (this.consumed) {
+            throw new IllegalStateException("Response content has been already consumed");
         }
     }
 
-    public String getContentString() throws IOException {
-        if (contentString != null)
-            return contentString;
-        if (this.getEntity() == null)
-            return null;
-        String contentCharset = this.getContentCharset();
-        return getContentString(contentCharset);
-    }
-
-    public String getContentString(String encoding) throws IOException {
-        if (contentString != null)
-            return contentString;
-        if (getContentByteArray() == null)
-            return null;
-        if (encoding == null)
-            contentString = new String(content);
-        else
-            contentString = new String(content, encoding);
-        return contentString;
-    }
-
-    public String getContentType() {
-        if (this.getEntity() == null)
-            throw new IllegalStateException("Response does not contain data");
-        Header contentType = this.getEntity().getContentType();
-        if (contentType == null)
-            throw new IllegalStateException(
-                    "Reponse does not contain Content-Type header");
-        return contentType.getElements()[0].getName();
-    }
-
-    public HttpEntity getEntity() {
-        return this.response.getEntity();
-    }
-
-    public Header getFirstHeader(String name) {
-        return this.response.getFirstHeader(name);
-    }
-
-    public Header[] getHeaders(String name) {
-        return this.response.getHeaders(name);
-    }
-
-    public Header getLastHeader(String name) {
-        return this.response.getLastHeader(name);
-    }
-
-    public Locale getLocale() {
-        return this.response.getLocale();
-    }
-
-    public HttpParams getParams() {
-        return this.response.getParams();
-    }
-
-    public ProtocolVersion getProtocolVersion() {
-        return this.response.getProtocolVersion();
-    }
-
-    public int getStatusCode() {
-        return this.getStatusLine().getStatusCode();
-    }
-
-    public StatusLine getStatusLine() {
-        return this.response.getStatusLine();
-    }
-
-    private String getValueOfHeader(String headerName) {
-        Header header = response.getFirstHeader(headerName);
-        if (header != null)
-            return header.getValue();
-        else
-            return null;
-    }
-
-    public HeaderIterator headerIterator() {
-        return this.response.headerIterator();
-    }
-
-    public HeaderIterator headerIterator(String name) {
-        return this.response.headerIterator(name);
-    }
-
-    public FluentResponse loadContent() throws IOException {
-        if (getEntity() == null)
-            content = null;
-        else {
-            content = EntityUtils.toByteArray(getEntity());
-            EntityUtils.consume(getEntity());
+    public void dispose() {
+        if (this.consumed) {
+            return;
+        }
+        try {
+            EntityUtils.consume(this.response.getEntity());
+        } catch (Exception ignore) {
+        } finally {
+            this.consumed = true;
         }
-        consumed = true;
-        return this;
-    }
-
-    public void removeHeader(Header header) {
-        this.response.removeHeader(header);
-    }
-
-    public void removeHeaders(String name) {
-        this.response.removeHeaders(name);
-    }
-
-    public void setEntity(HttpEntity entity) {
-        this.response.setEntity(entity);
-    }
-
-    public void setHeader(Header header) {
-        this.response.setHeader(header);
-    }
-
-    public void setHeader(String name, String value) {
-        this.response.setHeader(name, value);
-    }
-
-    public void setHeaders(Header[] headers) {
-        this.response.setHeaders(headers);
-    }
-
-    public void setLocale(Locale loc) {
-        this.response.setLocale(loc);
     }
 
-    public void setParams(HttpParams params) {
-        this.response.setParams(params);
+    public <T> T handle(final ResponseHandler<T> handler) throws ClientProtocolException, IOException {
+        assertNotConsumed();
+        try {
+            return handler.handleResponse(this.response);
+        } finally {
+            dispose();
+        }
     }
 
-    public void setReasonPhrase(String reason) throws IllegalStateException {
-        this.response.setReasonPhrase(reason);
-    }
+    public Content content() throws ClientProtocolException, IOException {
+        return handle(new ResponseHandler<Content>() {
 
-    public void setStatusCode(int code) throws IllegalStateException {
-        this.response.setStatusCode(code);
-    }
-
-    public void setStatusLine(ProtocolVersion ver, int code) {
-        this.response.setStatusLine(ver, code);
+            public Content handleResponse(
+                    final HttpResponse response) throws ClientProtocolException, IOException {
+                StatusLine statusLine = response.getStatusLine();
+                HttpEntity entity = response.getEntity();
+                if (statusLine.getStatusCode() >= 300) {
+                    throw new HttpResponseException(statusLine.getStatusCode(),
+                            statusLine.getReasonPhrase());
+                }
+                if (entity != null) {
+                    return new Content(EntityUtils.toByteArray(entity),
+                            ContentType.getOrDefault(entity));
+                } else {
+                    return null;
+                }
+            }
+
+        });
+    }
+
+    public HttpResponse response() throws IOException {
+        assertNotConsumed();
+        try {
+            HttpEntity entity = this.response.getEntity();
+            if (entity != null) {
+                this.response.setEntity(new ByteArrayEntity(EntityUtils.toByteArray(entity),
+                                ContentType.getOrDefault(entity)));
+            }
+            return this.response;
+        } finally {
+            this.consumed = true;
+        }
     }
 
-    public void setStatusLine(ProtocolVersion ver, int code, String reason) {
-        this.response.setStatusLine(ver, code, reason);
+    public void save(final File file) throws IOException {
+        assertNotConsumed();
+        FileOutputStream out = new FileOutputStream(file);
+        try {
+            HttpEntity entity = this.response.getEntity();
+            if (entity != null) {
+                entity.writeTo(out);
+            }
+        } finally {
+            this.consumed = true;
+            out.close();
+        }
     }
 
-    public void setStatusLine(StatusLine statusline) {
-        this.response.setStatusLine(statusline);
-    }
 }

Copied: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java (from r1182515, httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/HttpHeader.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java?p2=httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java&p1=httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/HttpHeader.java&r1=1182515&r2=1189320&rev=1189320&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/header/HttpHeader.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java Wed Oct 26 17:11:41 2011
@@ -24,13 +24,15 @@
  *
  */
 
-package org.apache.http.client.fluent.header;
+package org.apache.http.client.fluent;
+
+class HttpHeader {
 
-public class HttpHeader {
     public static final String CONTENT_LENGTH = "Content-Length";
     public static final String DATE = "Date";
-    public static final String CACHE_CONTROL = CacheControl.NAME;
-    public static final String CONTENT_TYPE = ContentType.NAME;
+    public static final String CACHE_CONTROL = "Cache-Control";
+    public static final String CONTENT_TYPE = "Content-Type";
     public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
     public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
+
 }

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/HttpHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message