Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d9c730c818
2 changed files with 29 additions and 9 deletions
14
pom.xml
14
pom.xml
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.rometools</groupId>
|
||||
<artifactId>rome-parent</artifactId>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>rome-fetcher</artifactId>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>rome-fetcher</name>
|
||||
|
@ -20,9 +20,9 @@
|
|||
<url>http://rometools.github.io/rome-fetcher/</url>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:rometools/rome-fetcher.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:rometools/rome-fetcher.git</developerConnection>
|
||||
<url>https://github.com/rometools/rome-fetcher/</url>
|
||||
<connection>scm:git:ssh://github.com/rometools/rome-fetcher.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/rometools/rome-fetcher.git</developerConnection>
|
||||
<url>https://github.com/rometools/rome-fetcher</url>
|
||||
</scm>
|
||||
|
||||
<developers>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<dependency>
|
||||
<groupId>com.rometools</groupId>
|
||||
<artifactId>rome</artifactId>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.InputStream;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.apache.commons.httpclient.Credentials;
|
||||
|
@ -50,6 +51,7 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
|||
private FeedFetcherCache feedInfoCache;
|
||||
private volatile HttpClientMethodCallbackIntf httpClientMethodCallback;
|
||||
private volatile HttpClientParams httpClientParams;
|
||||
private Map<String,String> customRequestHeaders;
|
||||
|
||||
public HttpClientFeedFetcher() {
|
||||
setHttpClientParams(new HttpClientParams());
|
||||
|
@ -161,6 +163,14 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
|||
return getHttpClientParams().getSoTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply any request headers to the HTTP method call.
|
||||
* @param customRequestHeaders
|
||||
*/
|
||||
public synchronized void setCustomRequestHeaders(final Map<String,String> customRequestHeaders) {
|
||||
this.customRequestHeaders = customRequestHeaders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyndFeed retrieveFeed(final URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException {
|
||||
return this.retrieveFeed(getUserAgent(), url);
|
||||
|
@ -196,8 +206,18 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
|||
final String urlStr = feedUrl.toString();
|
||||
|
||||
final HttpMethod method = new GetMethod(urlStr);
|
||||
method.addRequestHeader("Accept-Encoding", "gzip");
|
||||
method.addRequestHeader("User-Agent", userAgent);
|
||||
if (customRequestHeaders == null) {
|
||||
method.addRequestHeader("Accept-Encoding", "gzip");
|
||||
method.addRequestHeader("User-Agent", userAgent);
|
||||
|
||||
} else {
|
||||
for (final Map.Entry<String,String> entry : customRequestHeaders.entrySet()) {
|
||||
method.addRequestHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (!customRequestHeaders.containsKey("Accept-Encoding")) method.addRequestHeader("Accept-Encoding", "gzip");
|
||||
if (!customRequestHeaders.containsKey("User-Agent")) method.addRequestHeader("User-Agent", userAgent);
|
||||
}
|
||||
|
||||
method.setFollowRedirects(true);
|
||||
|
||||
if (httpClientMethodCallback != null) {
|
||||
|
|
Loading…
Reference in a new issue