You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2020/07/30 16:27:06 UTC

[httpcomponents-core] branch HTTPCORE-642/5.1.x created (now f62ca75)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch HTTPCORE-642/5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git.


      at f62ca75  HTTPCORE-642: Implement ConnectionFactory fluent builders

This branch includes the following new commits:

     new f62ca75  HTTPCORE-642: Implement ConnectionFactory fluent builders

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[httpcomponents-core] 01/01: HTTPCORE-642: Implement ConnectionFactory fluent builders

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch HTTPCORE-642/5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit f62ca751177733ea0df6192acb5fb956a83a7b33
Author: Carter Kozak <c4...@gmail.com>
AuthorDate: Wed Jul 29 17:40:09 2020 -0400

    HTTPCORE-642: Implement ConnectionFactory fluent builders
    
    This closes #208
---
 .../io/DefaultBHttpClientConnectionFactory.java    | 66 +++++++++++++++++++
 .../io/DefaultBHttpServerConnectionFactory.java    | 73 ++++++++++++++++++++++
 2 files changed, 139 insertions(+)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
index e9781df..a2d460b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
@@ -106,4 +106,70 @@ public class DefaultBHttpClientConnectionFactory
         return conn;
     }
 
+    /**
+     * Create a new {@link Builder}.
+     *
+     * @since 5.0.2
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * Builder for {@link DefaultBHttpClientConnectionFactory}.
+     *
+     * @since 5.0.2
+     */
+    public static final class Builder {
+        private Http1Config http1Config;
+        private CharCodingConfig charCodingConfig;
+        private ContentLengthStrategy incomingContentStrategy;
+        private ContentLengthStrategy outgoingContentStrategy;
+        private HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
+        private HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
+
+        private Builder() {}
+
+        public Builder http1Config(final Http1Config http1Config) {
+            this.http1Config = http1Config;
+            return this;
+        }
+
+        public Builder charCodingConfig(final CharCodingConfig charCodingConfig) {
+            this.charCodingConfig = charCodingConfig;
+            return this;
+        }
+
+        public Builder incomingContentStrategy(final ContentLengthStrategy incomingContentStrategy) {
+            this.incomingContentStrategy = incomingContentStrategy;
+            return this;
+        }
+
+        public Builder outgoingContentStrategy(final ContentLengthStrategy outgoingContentStrategy) {
+            this.outgoingContentStrategy = outgoingContentStrategy;
+            return this;
+        }
+
+        public Builder requestWriterFactory(
+                final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory) {
+            this.requestWriterFactory = requestWriterFactory;
+            return this;
+        }
+
+        public Builder responseParserFactory(
+                final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
+            this.responseParserFactory = responseParserFactory;
+            return this;
+        }
+
+        public DefaultBHttpClientConnectionFactory build() {
+            return new DefaultBHttpClientConnectionFactory(
+                    http1Config,
+                    charCodingConfig,
+                    incomingContentStrategy,
+                    outgoingContentStrategy,
+                    requestWriterFactory,
+                    responseParserFactory);
+        }
+    }
 }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
index d74c528..111145b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
@@ -107,4 +107,77 @@ public class DefaultBHttpServerConnectionFactory implements HttpConnectionFactor
         return conn;
     }
 
+    /**
+     * Create a new {@link Builder}.
+     *
+     * @since 5.0.2
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     * Builder for {@link DefaultBHttpServerConnectionFactory}.
+     *
+     * @since 5.0.2
+     */
+    public static final class Builder {
+        private String scheme;
+        private Http1Config http1Config;
+        private CharCodingConfig charCodingConfig;
+        private ContentLengthStrategy incomingContentStrategy;
+        private ContentLengthStrategy outgoingContentStrategy;
+        private HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory;
+        private HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory;
+
+        private Builder() {}
+
+        public Builder scheme(final String scheme) {
+            this.scheme = scheme;
+            return this;
+        }
+
+        public Builder http1Config(final Http1Config http1Config) {
+            this.http1Config = http1Config;
+            return this;
+        }
+
+        public Builder charCodingConfig(final CharCodingConfig charCodingConfig) {
+            this.charCodingConfig = charCodingConfig;
+            return this;
+        }
+
+        public Builder incomingContentStrategy(final ContentLengthStrategy incomingContentStrategy) {
+            this.incomingContentStrategy = incomingContentStrategy;
+            return this;
+        }
+
+        public Builder outgoingContentStrategy(final ContentLengthStrategy outgoingContentStrategy) {
+            this.outgoingContentStrategy = outgoingContentStrategy;
+            return this;
+        }
+
+        public Builder requestParserFactory(
+                final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory) {
+            this.requestParserFactory = requestParserFactory;
+            return this;
+        }
+
+        public Builder responseWriterFactory(
+                final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
+            this.responseWriterFactory = responseWriterFactory;
+            return this;
+        }
+
+        public DefaultBHttpServerConnectionFactory build() {
+            return new DefaultBHttpServerConnectionFactory(
+                    scheme,
+                    http1Config,
+                    charCodingConfig,
+                    incomingContentStrategy,
+                    outgoingContentStrategy,
+                    requestParserFactory,
+                    responseWriterFactory);
+        }
+    }
 }