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 Windows ISO downloads #42

Closed
wants to merge 1 commit into from
Closed

Fixed Windows ISO downloads #42

wants to merge 1 commit into from

Conversation

williambulin
Copy link
Contributor

@williambulin williambulin commented Aug 13, 2022

Fix for issue #41, the request now requires the Referer to be set properly.

@williambulin williambulin changed the title Fixed Windows 11 downloads Fixed Windows ISO downloads Aug 13, 2022
@williambulin williambulin marked this pull request as ready for review August 13, 2022 13:12
@williambulin
Copy link
Contributor Author

Just specifying: while the referer contains 'windows11', it does indeed work for Windows 10 and 8.1 as well.

@@ -801,7 +801,7 @@ function Get-Windows-Download-Links([int]$SelectedVersion, [int]$SelectedRelease

try {
$Is64 = [Environment]::Is64BitOperatingSystem
$r = Invoke-WebRequest -Method Post -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
$r = Invoke-WebRequest -Method Post -Headers @{'Referer' = 'https://www.microsoft.com/software-download/windows11'} -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the windows version variable: $WindowsVersions[$SelectedVersion][0][1]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to do that for now, because https://www.microsoft.com/software-download/windows8.1 is not a valid page, and that's the URL we'd get for 8.1...
As long as Microsoft's server don't seem to care about the version, using window11 should be good enough.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with that KISS approach even though this edge case with 8.1 / windows8ISO would be easily handlebar.

@pbatard pbatard closed this in 0287fe2 Aug 13, 2022
@AgentSam
Copy link

This was a partial fix which, while helpful, caused some issues for users of Windows 7 SP1 systems.

The full-fix, which provides backward-compatibility with Windows 7, can seen in this commit:
Fix Windows 7 "Referer header" error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants