remove all remaining references to httpclient4

This commit is contained in:
Athou
2023-12-26 08:15:35 +01:00
parent 5ba248eaba
commit b49d35f181
4 changed files with 13 additions and 21 deletions

View File

@@ -128,7 +128,7 @@ public class HttpGetter implements Managed {
response.getUrlAfterRedirect()); response.getUrlAfterRedirect());
} }
private CloseableHttpClient newClient(String userAgent, int poolSize) { private static CloseableHttpClient newClient(String userAgent, int poolSize) {
SSLFactory sslFactory = SSLFactory.builder().withUnsafeTrustMaterial().withUnsafeHostnameVerifier().build(); SSLFactory sslFactory = SSLFactory.builder().withUnsafeTrustMaterial().withUnsafeHostnameVerifier().build();
List<Header> headers = new ArrayList<>(); List<Header> headers = new ArrayList<>();

View File

@@ -2,11 +2,10 @@ package com.commafeed.backend.favicon;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import org.apache.http.NameValuePair; import org.apache.hc.core5.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils; import org.apache.hc.core5.net.URIBuilder;
import com.commafeed.backend.HttpGetter; import com.commafeed.backend.HttpGetter;
import com.commafeed.backend.HttpGetter.HttpResult; import com.commafeed.backend.HttpGetter.HttpResult;
@@ -66,13 +65,9 @@ public class FacebookFaviconFetcher extends AbstractFaviconFetcher {
log.debug("could not parse url", e); log.debug("could not parse url", e);
return null; return null;
} }
List<NameValuePair> params = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8);
for (NameValuePair param : params) { List<NameValuePair> params = new URIBuilder(uri).getQueryParams();
if ("id".equals(param.getName())) { return params.stream().filter(p -> "id".equals(p.getName())).map(NameValuePair::getValue).findFirst().orElse(null);
return param.getValue();
}
}
return null;
} }
} }

View File

@@ -1,12 +1,13 @@
package com.commafeed.backend.favicon; package com.commafeed.backend.favicon;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.apache.http.NameValuePair; import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.client.utils.URLEncodedUtils; 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.CommaFeedConfiguration;
import com.commafeed.backend.HttpGetter; import com.commafeed.backend.HttpGetter;
@@ -52,7 +53,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
byte[] bytes = null; byte[] bytes = null;
String contentType = null; String contentType = null;
try { 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> 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> channelId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("channel_id")).findFirst();
Optional<NameValuePair> playlistId = params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("playlist_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()); response = fetchForPlaylist(youtube, googleAuthKey, playlistId.get().getValue());
} }
if (response == null) { if (MapUtils.isEmpty(response) || CollectionUtils.isEmpty(response.getItems())) {
return null;
}
if (response.getItems().isEmpty()) {
log.debug("youtube api returned no items"); log.debug("youtube api returned no items");
return null; return null;
} }

View File

@@ -9,7 +9,7 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; 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.codahale.metrics.annotation.Timed;
import com.commafeed.CommaFeedApplication; import com.commafeed.CommaFeedApplication;