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

Plugin proxy – handle artifacts hosted on windows.net #889

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Dec 20, 2023

Fixes an issue reported by @gziolo:

WordPress/gutenberg#57256 - I can’t preview this PR using Playground https://playground.wordpress.net/gutenberg.html. What do I miss? All CI checks are green.

The culprit was that GitHub hosts that artifact on another domain: productionresultssa0.blob.core.windows.net. The current file_get_contents call follows the redirection URL and resends the same HTTP headers. That used to be fine, but now the windows.net host rejects those headers.

This PR ensures we don't implicitly follow the 302 redirect, but parse the target URL and send an explicit request with a fresh set of HTTP headers. As a bonus, this makes the download much faster as we now use the streamHttpResponse function which immediately passes the response bytes back to the browser instead of buffering the entire response first.

This PR also switches from HEAD-request-based PR validation to the same Query params–based one as the wordpress.html previewer uses.

Testing instructions

Try to preview the above PR in the Gutenberg PR previewer on https://playground.wordpress.net/gutenberg.html and confirm that it works now (this fix is already deployed).

@adamziel adamziel changed the title Plugin proxy – handle 302 redirects sent by GitHub API Plugin proxy – handle artifacts hosted on windows.net Dec 20, 2023
@adamziel adamziel merged commit 768a74f into trunk Dec 20, 2023
5 checks passed
@adamziel adamziel deleted the fix-plugin-proxy branch December 20, 2023 16:09
@gziolo
Copy link
Member

gziolo commented Dec 20, 2023

Lovely. I’m impressed with how quickly you resolved it. Thank you so much!

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

Successfully merging this pull request may close these issues.

2 participants