forked from Archives/Athou_commafeed
actually this works fine, the wrong constructor was injected
This commit is contained in:
@@ -7,6 +7,7 @@ v 2.0.2
|
|||||||
- fields autocomplete is disabled on the profile page
|
- fields autocomplete is disabled on the profile page
|
||||||
- users are able to delete their account again
|
- users are able to delete their account again
|
||||||
- chinese and malaysian translation files are now correctly loaded
|
- chinese and malaysian translation files are now correctly loaded
|
||||||
|
- software version in user-agent when fetching feeds is no longer hardcoded
|
||||||
- admin settings page is now read only, settings are configured in config.yml
|
- admin settings page is now read only, settings are configured in config.yml
|
||||||
- added link to metrics on the admin settings page
|
- added link to metrics on the admin settings page
|
||||||
- Rome (rss library) upgrade to 1.5.0
|
- Rome (rss library) upgrade to 1.5.0
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ import org.apache.http.impl.client.HttpClients;
|
|||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
import com.commafeed.CommaFeedConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smart HTTP getter: handles gzip, ssl, last modified and etag headers
|
* Smart HTTP getter: handles gzip, ssl, last modified and etag headers
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class HttpGetter {
|
public class HttpGetter {
|
||||||
|
|
||||||
private static final String USER_AGENT = "CommaFeed/2.0 (http://www.commafeed.com)";
|
|
||||||
private static final String ACCEPT_LANGUAGE = "en";
|
private static final String ACCEPT_LANGUAGE = "en";
|
||||||
private static final String PRAGMA_NO_CACHE = "No-cache";
|
private static final String PRAGMA_NO_CACHE = "No-cache";
|
||||||
private static final String CACHE_CONTROL_NO_CACHE = "no-cache";
|
private static final String CACHE_CONTROL_NO_CACHE = "no-cache";
|
||||||
@@ -98,6 +98,13 @@ public class HttpGetter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String userAgent;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public HttpGetter(CommaFeedConfiguration config) {
|
||||||
|
this.userAgent = String.format("CommaFeed/%s (https://www.commafeed.com)", config.getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
public HttpResult getBinary(String url, int timeout) throws ClientProtocolException, IOException, NotModifiedException {
|
public HttpResult getBinary(String url, int timeout) throws ClientProtocolException, IOException, NotModifiedException {
|
||||||
return getBinary(url, null, null, timeout);
|
return getBinary(url, null, null, timeout);
|
||||||
}
|
}
|
||||||
@@ -130,7 +137,7 @@ public class HttpGetter {
|
|||||||
httpget.addHeader(HttpHeaders.ACCEPT_LANGUAGE, ACCEPT_LANGUAGE);
|
httpget.addHeader(HttpHeaders.ACCEPT_LANGUAGE, ACCEPT_LANGUAGE);
|
||||||
httpget.addHeader(HttpHeaders.PRAGMA, PRAGMA_NO_CACHE);
|
httpget.addHeader(HttpHeaders.PRAGMA, PRAGMA_NO_CACHE);
|
||||||
httpget.addHeader(HttpHeaders.CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
|
httpget.addHeader(HttpHeaders.CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
|
||||||
httpget.addHeader(HttpHeaders.USER_AGENT, USER_AGENT);
|
httpget.addHeader(HttpHeaders.USER_AGENT, userAgent);
|
||||||
|
|
||||||
if (lastModified != null) {
|
if (lastModified != null) {
|
||||||
httpget.addHeader(HttpHeaders.IF_MODIFIED_SINCE, lastModified);
|
httpget.addHeader(HttpHeaders.IF_MODIFIED_SINCE, lastModified);
|
||||||
|
|||||||
Reference in New Issue
Block a user