Repository: nifi Updated Branches: refs/heads/master 8a28395e9 -> c1ad91359
NIFI-1342 Added default User-Agent in PostHttp This closes #1021 Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/c1ad9135 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/c1ad9135 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/c1ad9135 Branch: refs/heads/master Commit: c1ad913598c9c41fdc99a53d9939fece9c3250b9 Parents: 8a28395 Author: Pierre Villard <pierre.villard...@gmail.com> Authored: Wed Sep 14 17:59:17 2016 +0200 Committer: Oleg Zhurakousky <o...@suitcase.io> Committed: Thu Sep 15 09:57:09 2016 -0400 ---------------------------------------------------------------------- .../java/org/apache/nifi/processors/standard/PostHTTP.java | 2 ++ .../org/apache/nifi/processors/standard/TestPostHTTP.java | 7 +++++++ 2 files changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/c1ad9135/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java index 37b307e..44b7973 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java @@ -82,6 +82,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpCoreContext; import org.apache.http.util.EntityUtils; +import org.apache.http.util.VersionInfo; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; import org.apache.nifi.annotation.behavior.SupportsBatching; @@ -194,6 +195,7 @@ public class PostHTTP extends AbstractProcessor { .description("What to report as the User Agent when we connect to the remote server") .required(false) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .defaultValue(VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client", HttpClientBuilder.class)) .build(); public static final PropertyDescriptor COMPRESSION_LEVEL = new PropertyDescriptor.Builder() .name("Compression Level") http://git-wip-us.apache.org/repos/asf/nifi/blob/c1ad9135/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPostHTTP.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPostHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPostHTTP.java index edff3b4..cfda2ef 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPostHTTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPostHTTP.java @@ -434,4 +434,11 @@ public class TestPostHTTP { Assert.assertEquals(suppliedMimeType, lastPostHeaders.get(PostHTTP.CONTENT_TYPE_HEADER)); Assert.assertEquals("4700",lastPostHeaders.get("Content-Length")); } + + @Test + public void testDefaultUserAgent() throws Exception { + setup(null); + Assert.assertTrue(runner.getProcessContext().getProperty(PostHTTP.USER_AGENT).getValue().startsWith("Apache-HttpClient")); + } + }