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

Infinite loop on sub path redirects #145

Open
Gronex opened this issue Nov 1, 2024 · 0 comments
Open

Infinite loop on sub path redirects #145

Gronex opened this issue Nov 1, 2024 · 0 comments

Comments

@Gronex
Copy link

Gronex commented Nov 1, 2024

If i have a redirect like /catalog-content -> /catalog-content/true-catalog i enter a loop.

If i submit fx /catalog-content, the first redirect will lead me to /catalog-content/true-catalog, which will then send me to /catalog-content/true-catalog/true-catalog. This repeats until the browser stops it.

I updated the test case that is checking for it to make sure it was not something else in our environment, and this version does reproduce the issue:

        [Fact]
        public async Task Request_does_not_build_forever()
        {
            var builder = new RedirectServerBuilder();

            builder.AddRedirect("/catalog-content", "/catalog-content/true-catalog");
            builder.AddRedirect("/catalog-content/nice-sweater", "/catalog-content");
            builder.AddRedirect("/catalog-content/redirect-by-code", "/catalog-content/nice-sweater");

            using var server = builder.Build();
            using var client = server.CreateClient();

            var response = await client.GetAsync("/catalog-content/redirect-by-code");

            Assert.NotNull(response);
            Assert.Equal(HttpStatusCode.MovedPermanently, response.StatusCode);

            var location = response.Headers.Location?.ToString();
            Assert.Equal("/catalog-content/nice-sweater", location);

            var iterations = 0;

            while (response.StatusCode == HttpStatusCode.MovedPermanently)
            {
                response = await client.GetAsync(location);
                location = response.Headers.Location?.ToString();

                Assert.True(++iterations < 100);
            }
        }

In the old test the name of the subpath was the same as the root, which apparently does act as it should.

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

No branches or pull requests

1 participant