diff --git a/config.dev.yml b/config.dev.yml index a0d6d0e9..b8893b9b 100644 --- a/config.dev.yml +++ b/config.dev.yml @@ -67,6 +67,9 @@ app: # announcement string displayed on the main page announcement: + # user-agent string that will be used by the http client, leave empty for the default one + userAgent: + # Database connection # ------------------- # for MySQL diff --git a/config.yml.example b/config.yml.example index 65409954..0eb800df 100644 --- a/config.yml.example +++ b/config.yml.example @@ -68,6 +68,9 @@ app: # announcement string displayed on the main page announcement: + # user-agent string that will be used by the http client, leave empty for the default one + userAgent: + # Database connection # ------------------- # for MySQL diff --git a/src/main/java/com/commafeed/CommaFeedConfiguration.java b/src/main/java/com/commafeed/CommaFeedConfiguration.java index 14e5e17a..a18543c2 100644 --- a/src/main/java/com/commafeed/CommaFeedConfiguration.java +++ b/src/main/java/com/commafeed/CommaFeedConfiguration.java @@ -142,6 +142,8 @@ public class CommaFeedConfiguration extends Configuration { @Valid private String announcement; + private String userAgent; + public Date getUnreadThreshold() { int keepStatusDays = getKeepStatusDays(); return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null; diff --git a/src/main/java/com/commafeed/backend/HttpGetter.java b/src/main/java/com/commafeed/backend/HttpGetter.java index 66ea790b..03f4502a 100644 --- a/src/main/java/com/commafeed/backend/HttpGetter.java +++ b/src/main/java/com/commafeed/backend/HttpGetter.java @@ -70,7 +70,10 @@ public class HttpGetter { @Inject public HttpGetter(CommaFeedConfiguration config) { - this.userAgent = String.format("CommaFeed/%s (https://github.com/Athou/commafeed)", config.getVersion()); + this.userAgent = config.getApplicationSettings().getUserAgent(); + if (this.userAgent == null) { + this.userAgent = String.format("CommaFeed/%s (https://github.com/Athou/commafeed)", config.getVersion()); + } } public HttpResult getBinary(String url, int timeout) throws ClientProtocolException, IOException, NotModifiedException {