I have this link on my page (page1):
<a href="@{Controller.action1().secure()}">Link1</a>
that takes me to a page (page2) over https. How to make a link on page2 that takes me back from https to http? I thought @@ notation would do the trick:
<a href="@@{Controller.action2()}">Link2</a>
but it doesn't, action2 also gets called via https.
Go to chrome://net-internals/#hsts . Enter example.com under Delete domain security policies and press the Delete button. Now go to chrome://settings/clearBrowserData , tick the box Cached images and files and press click the button Clear data.
No. Modern browsers don't downgrade to plain HTTP autonomously. If a certificate is invalid, the user will simply see a certificate warning (and eventually an option to add an exception).
Play doesn't have a method that would be opposite to secure(), but you can implement it yourself with custom JavaExtension:
import play.templates.JavaExtensions;
import play.mvc.Router.ActionDefinition;
public class MyExtensions extends play.templates.JavaExtensions {
public static String unsecure(ActionDefinition action) {
if (!action.url.contains("http://") && !action.url.contains("https://")) {
action.absolute();
}
action.url = action.url.replace("https:", "http:");
return action.url;
}
Custom extension methods should return String
, and the parameter will hold the enhanced object, as the documentation suggests. The code is almost identical to the secure method's code.
With this method you can now use:
href="@{Controller.action2().unsecure()}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With