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"?>
|
<?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"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.rometools</groupId>
|
<groupId>com.rometools</groupId>
|
||||||
<artifactId>rome-parent</artifactId>
|
<artifactId>rome-parent</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>rome-fetcher</artifactId>
|
<artifactId>rome-fetcher</artifactId>
|
||||||
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>rome-fetcher</name>
|
<name>rome-fetcher</name>
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
<url>http://rometools.github.io/rome-fetcher/</url>
|
<url>http://rometools.github.io/rome-fetcher/</url>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:rometools/rome-fetcher.git</connection>
|
<connection>scm:git:ssh://github.com/rometools/rome-fetcher.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:rometools/rome-fetcher.git</developerConnection>
|
<developerConnection>scm:git:ssh://git@github.com/rometools/rome-fetcher.git</developerConnection>
|
||||||
<url>https://github.com/rometools/rome-fetcher/</url>
|
<url>https://github.com/rometools/rome-fetcher</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rometools</groupId>
|
<groupId>com.rometools</groupId>
|
||||||
<artifactId>rome</artifactId>
|
<artifactId>rome</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-httpclient</groupId>
|
<groupId>commons-httpclient</groupId>
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.Credentials;
|
import org.apache.commons.httpclient.Credentials;
|
||||||
|
@ -50,6 +51,7 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
||||||
private FeedFetcherCache feedInfoCache;
|
private FeedFetcherCache feedInfoCache;
|
||||||
private volatile HttpClientMethodCallbackIntf httpClientMethodCallback;
|
private volatile HttpClientMethodCallbackIntf httpClientMethodCallback;
|
||||||
private volatile HttpClientParams httpClientParams;
|
private volatile HttpClientParams httpClientParams;
|
||||||
|
private Map<String,String> customRequestHeaders;
|
||||||
|
|
||||||
public HttpClientFeedFetcher() {
|
public HttpClientFeedFetcher() {
|
||||||
setHttpClientParams(new HttpClientParams());
|
setHttpClientParams(new HttpClientParams());
|
||||||
|
@ -160,6 +162,14 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
||||||
public int getReadTimeout() {
|
public int getReadTimeout() {
|
||||||
return getHttpClientParams().getSoTimeout();
|
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
|
@Override
|
||||||
public SyndFeed retrieveFeed(final URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException {
|
public SyndFeed retrieveFeed(final URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException {
|
||||||
|
@ -196,8 +206,18 @@ public class HttpClientFeedFetcher extends AbstractFeedFetcher {
|
||||||
final String urlStr = feedUrl.toString();
|
final String urlStr = feedUrl.toString();
|
||||||
|
|
||||||
final HttpMethod method = new GetMethod(urlStr);
|
final HttpMethod method = new GetMethod(urlStr);
|
||||||
method.addRequestHeader("Accept-Encoding", "gzip");
|
if (customRequestHeaders == null) {
|
||||||
method.addRequestHeader("User-Agent", userAgent);
|
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);
|
method.setFollowRedirects(true);
|
||||||
|
|
||||||
if (httpClientMethodCallback != null) {
|
if (httpClientMethodCallback != null) {
|
||||||
|
|
Loading…
Reference in a new issue