forked from Archives/Athou_commafeed
remove all remaining references to httpclient4
This commit is contained in:
@@ -128,7 +128,7 @@ public class HttpGetter implements Managed {
|
||||
response.getUrlAfterRedirect());
|
||||
}
|
||||
|
||||
private CloseableHttpClient newClient(String userAgent, int poolSize) {
|
||||
private static CloseableHttpClient newClient(String userAgent, int poolSize) {
|
||||
SSLFactory sslFactory = SSLFactory.builder().withUnsafeTrustMaterial().withUnsafeHostnameVerifier().build();
|
||||
|
||||
List<Header> headers = new ArrayList<>();
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.commafeed.backend.favicon;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.hc.core5.http.NameValuePair;
|
||||
import org.apache.hc.core5.net.URIBuilder;
|
||||
|
||||
import com.commafeed.backend.HttpGetter;
|
||||
import com.commafeed.backend.HttpGetter.HttpResult;
|
||||
@@ -66,13 +65,9 @@ public class FacebookFaviconFetcher extends AbstractFaviconFetcher {
|
||||
log.debug("could not parse url", e);
|
||||
return null;
|
||||
}
|
||||
List<NameValuePair> params = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8);
|
||||
for (NameValuePair param : params) {
|
||||
if ("id".equals(param.getName())) {
|
||||
return param.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
List<NameValuePair> params = new URIBuilder(uri).getQueryParams();
|
||||
return params.stream().filter(p -> "id".equals(p.getName())).map(NameValuePair::getValue).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.commafeed.backend.favicon;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.hc.core5.http.NameValuePair;
|
||||
import org.apache.hc.core5.net.URIBuilder;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.HttpGetter;
|
||||
@@ -52,7 +53,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
byte[] bytes = null;
|
||||
String contentType = null;
|
||||
try {
|
||||
List<NameValuePair> params = URLEncodedUtils.parse(url.substring(url.indexOf("?") + 1), StandardCharsets.UTF_8);
|
||||
List<NameValuePair> params = new URIBuilder(url).getQueryParams();
|
||||
Optional<NameValuePair> userId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("user")).findFirst();
|
||||
Optional<NameValuePair> channelId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("channel_id")).findFirst();
|
||||
Optional<NameValuePair> playlistId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("playlist_id")).findFirst();
|
||||
@@ -72,11 +73,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
response = fetchForPlaylist(youtube, googleAuthKey, playlistId.get().getValue());
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.getItems().isEmpty()) {
|
||||
if (MapUtils.isEmpty(response) || CollectionUtils.isEmpty(response.getItems())) {
|
||||
log.debug("youtube api returned no items");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.hc.core5.net.URIBuilder;
|
||||
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.commafeed.CommaFeedApplication;
|
||||
|
||||
Reference in New Issue
Block a user