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

Assert that redirects go directly to their target location #1814

Merged
merged 1 commit into from Sep 1, 2022

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Aug 31, 2022

Previously the assertion allowed multiple redirect steps as long as it eventually got to the target. Now it's checked that the very first response directly returns a Location header to the final target.

This should save a couple RTTs for some urls.

Previously the assertion allowed multiple redirect steps as long as it
eventually got to the target. Now it's checked that the very first
response directly returns a `Location` header to the final target.
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Aug 31, 2022
@@ -759,7 +763,7 @@ mod test {
.create()
.unwrap();
let web = env.frontend();
assert_redirect("/bat//", "/bat/latest/bat/", web)?;
assert_redirect_unchecked("/bat//", "/bat/", web)?;
Copy link
Member Author

Choose a reason for hiding this comment

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

This redirect is handled by iron, so there's no easy way to make it go directly to the final target.

@@ -92,6 +92,12 @@ impl<'a> RenderingTimesRecorder<'a> {

fn record_current(&mut self) {
if let Some(current) = self.current.take() {
#[cfg(test)]
log::debug!(
"rendering time - {}: {:?}",
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this while trying to figure out why I was getting timeouts from the two reqwest clients deadlocking, but I thought it could be useful to leave in.

assert_redirect_common(path, expected_target, web)
}

/// Make sure that a URL redirects to a specific page, and that the target exists and is not another redirect
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Make sure that a URL redirects to a specific page, and that the target exists and is not another redirect
/// Make sure that a URL redirects to a specific page, that the target exists and is not another redirect

(nit)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the double and is more correct, even if a little weird

Make sure (that a URL redirects to a specific page), and (that the target (exists) and (is not another redirect)).

vs

Make sure (that a URL redirects to a specific page), (that the target exists) and (is not another redirect).

routes.internal_page(
"/rustc/",
super::rustdoc::RustLangRedirector::new("nightly", "nightly-rustc"),
);
Copy link
Member

Choose a reason for hiding this comment

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

it feels odd duplicating this here, but since I'm (still 😅 😉 ) working on the iron/axum rewrite we can leave it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

My next PR deletes this whole section 😁

@syphar
Copy link
Member

syphar commented Sep 1, 2022

LGTM, IMO can be merged with or without fixing the nit/typo :)

@syphar syphar added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Sep 1, 2022
@syphar
Copy link
Member

syphar commented Sep 1, 2022

and thank you for this optimization!

@Nemo157 Nemo157 merged commit 69070c1 into rust-lang:master Sep 1, 2022
@Nemo157 Nemo157 deleted the direct-redirect branch September 1, 2022 19:42
@github-actions github-actions bot added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Sep 1, 2022
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Sep 3, 2022
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

2 participants