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

Middleware/Rewrite: Update XML comments for "AddRedirect" to indicate status code. #57224

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

ctolkien
Copy link
Contributor

@ctolkien ctolkien commented Aug 8, 2024

Tweak XML comments for AddRedirect extension methods

Update XML comments to indicate the status code that is returned with this overload.

Description

Rationale here is I have just been burnt from thinking our site had permanent redirects in place, when they were actually temporary. There is no visibility into what status code is being used with this overload, unless you find it in the documentation. This just exposes the status code in the code comments.

Also then tweaked the comment for the AddRedirectToHttpsPermanent method to make it consistent.

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

(Did not create a ticket first for this, as it didn't seem to fit the format of bug/feature)

@ctolkien ctolkien requested a review from BrennanConroy as a code owner August 8, 2024 02:36
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares label Aug 8, 2024
@dotnet-policy-service dotnet-policy-service bot added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member labels Aug 8, 2024
@@ -76,7 +76,7 @@ public static RewriteOptions AddRedirect(this RewriteOptions options, [StringSyn
}

/// <summary>
/// Redirect a request to https if the incoming request is http, with returning a 301
/// Redirect a request to https if the incoming request is http, with returning a 301 - Moved Permanently status code.
/// status code for permanently redirected.
Copy link
Member

Choose a reason for hiding this comment

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

status code for permanently redirected.

This one already says it sets 301 meaning permanently redirected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Also then tweaked the comment for the AddRedirectToHttpsPermanent method to make it consistent.. This is the only other overload in this class which mentions a status code, so it felt like the two should be aligned.

I can revert the change to this comment, and alter the comment for AddRedirect to be simply ,with returning a 302 (without the - Found status code), which would then make it consistent with the AddRedirectToHttpsPermanent comments if that is preferable.

Copy link
Member

Choose a reason for hiding this comment

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

Changing the format is fine, but you kept part of the old comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is intentional? It just adds the text version of what the status code represents, in addition to the numeric status code.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, if it's intentional then status -> Status.
Bit I think you should just remove status code for permanently redirected. now.

Copy link
Contributor Author

@ctolkien ctolkien Aug 26, 2024

Choose a reason for hiding this comment

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

Oh wow, I completely missed that the xml comment for the permanent option was carried on to the next line, my mistake - no wonder you were confused about what I was doing. I have reverted the change to the permanent redirect option, and now aligned the 302 option to match what the permanent one does.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 16, 2024
* Align 302 coments to match.
@BrennanConroy BrennanConroy merged commit 7c39886 into dotnet:main Aug 26, 2024
26 checks passed
@BrennanConroy
Copy link
Member

Thanks @ctolkien

@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants