-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
fix: fixes redirects #7136
fix: fixes redirects #7136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve, but I think you forgot to export the function !
@@ -435,6 +435,33 @@ sub process_template($template_filename, $template_data_ref, $result_content_ref | |||
} | |||
|
|||
|
|||
=head2 redirect($status_code, $redirect_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to @yuktea : typically a function that, when we will split is part of "http utils" more than display.
@@ -435,6 +435,33 @@ sub process_template($template_filename, $template_data_ref, $result_content_ref | |||
} | |||
|
|||
|
|||
=head2 redirect($status_code, $redirect_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't you forget to add it to export ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I'll add it. I just noticed I was also exporting init which has been renamed to init_request
|
||
$r->headers_out->set(Location => $redirect_url); | ||
$r->status($status_code); | ||
# note: under mod_perl, exit() will end the request without terminating the Apache mod_perl process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the comment :-)
@@ -472,7 +499,7 @@ sub init_request() { | |||
$bodyabout = ''; | |||
$admin = 0; | |||
|
|||
my $r = shift; | |||
my $r = Apache2::RequestUtil->request(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove the code below:
if (not defined $r) {
$r = Apache2::RequestUtil->request();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
Kudos, SonarCloud Quality Gate passed! |
The recent refactor of init() -> init_request() broke the way we did redirects (e.g. when someone make a request for https://fr-fr.openfoodfacts.org/categorie/cafe , we redirect to https://fr.openfoodfacts.org/categorie/cafes )
In fact previously it only worked for requests proceessed by display.pl (so everything except URLs starting by /cgi/)
This fixes it and ensure the request is terminated as soon as we have determined that we should redirect to a different url.