Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed(#812) not grabbing downloads from AMD driver site #824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ app/.classpath
app/.project
app/.settings/*
app/target/*
.idea
app/xdman.iml
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;
}

}