Merge pull request #5280 from ByteHamster/fix-null-location

Fix crash when a server returns a null location
This commit is contained in:
ByteHamster 2021-07-18 10:00:59 +02:00 committed by GitHub
commit f4c92e88db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ public class AntennapodHttpClient {
if (response.code() == HttpURLConnection.HTTP_MOVED_PERM if (response.code() == HttpURLConnection.HTTP_MOVED_PERM
|| response.code() == StatusLine.HTTP_PERM_REDIRECT) { || response.code() == StatusLine.HTTP_PERM_REDIRECT) {
String location = response.header("Location"); String location = response.header("Location");
if (location == null) {
return response;
}
if (location.startsWith("/")) { // URL is not absolute, but relative if (location.startsWith("/")) { // URL is not absolute, but relative
HttpUrl url = request.url(); HttpUrl url = request.url();
location = url.scheme() + "://" + url.host() + location; location = url.scheme() + "://" + url.host() + location;