Fix for amazon.{ca,com} link previews
(cherry picked from commit 967757b1e012609064b4b62f884060835b47f238)
This commit is contained in:
parent
daca2a8706
commit
6cfd420f8f
1 changed files with 8 additions and 1 deletions
|
@ -1987,7 +1987,14 @@ public class XmppConnectionService extends Service {
|
|||
try {
|
||||
HttpUrl url = HttpUrl.parse(link.toString());
|
||||
OkHttpClient http = getHttpConnectionManager().buildHttpClient(url, account, 5, false);
|
||||
okhttp3.Response response = http.newCall(new okhttp3.Request.Builder().url(url).head().build()).execute();
|
||||
final var request = new okhttp3.Request.Builder().url(url).head().build();
|
||||
okhttp3.Response response = null;
|
||||
if ("www.amazon.com".equals(link.getHost()) || "www.amazon.ca".equals(link.getHost())) {
|
||||
// Amazon blocks HEAD
|
||||
response = new okhttp3.Response.Builder().request(request).protocol(okhttp3.Protocol.HTTP_1_1).code(200).message("OK").addHeader("Content-Type", "text/html").build();
|
||||
} else {
|
||||
response = http.newCall(request).execute();
|
||||
}
|
||||
final String mimeType = response.header("Content-Type") == null ? "" : response.header("Content-Type");
|
||||
final boolean image = mimeType.startsWith("image/");
|
||||
final boolean audio = mimeType.startsWith("audio/");
|
||||
|
|
Loading…
Reference in a new issue