Skip to content

Commit

Permalink
Fixed not grabbing downloads from AMD driver site
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanmostafa11 committed May 3, 2022
1 parent d18f7ba commit 8257a97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/xdman/XDMApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ private void startDownload(String id, HttpMetadata metadata, DownloadEntry ent,
if (metadata.getType() == XDMConstants.FTP) {
d = new FtpDownloader(id, ent.getTempFolder(), metadata);
} else {
HttpDownloader.injectReferrerHeaders(metadata);
d = new HttpDownloader(id, ent.getTempFolder(), metadata);
}
}
Expand Down Expand Up @@ -1402,4 +1403,4 @@ public ArrayList<VideoPopupItem> getVideoItemsList() {
public MainWindow getMainWindow() {
return mainWindow;
}
}
}
23 changes: 23 additions & 0 deletions app/src/main/java/xdman/downloaders/http/HttpDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,27 @@ public HttpMetadata getMetadata() {
return this.metadata;
}

public static void injectReferrerHeaders(HttpMetadata metadata)
{
String referrer = getReferrer(metadata.getUrl());

if (StringUtils.isNullOrEmpty(referrer))
return;

var headers = metadata.getHeaders();
headers.setValue("referer", referrer);
headers.setValue("origin", referrer);
metadata.setHeaders(headers);

}

// should contain different referrers of different sites
private static String getReferrer(String url)
{
if (url.contains("amd"))
return "https://www.amd.com/";

return null;
}

}

0 comments on commit 8257a97

Please sign in to comment.