Rails 3.1 强制使用常规 HTTP [英] Rails 3.1 Force Regular HTTP

查看:30
本文介绍了Rails 3.1 强制使用常规 HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我一直在使用 ssl_requirement 来让我们细粒度地控制通过 ssl 提供的页面并且通过普通 http 提供服务.

Previously, I had been using ssl_requirement to give us fine grained control over which pages were served over ssl and which were served over plain http.

根据 ssl_requirement 自己的 wiki,它已被 rails 3.1 的 强制 SSL.然而,情况似乎并非如此.强制 SSL 似乎没有公开相反方向的选项,无法强制页面通过常规 http 发送.

According to the ssl_requirement's own wiki, it has been superseded by rails 3.1's Force SSL. However this does not seem to be the case. Force SSL doesn't seem to expose an option to go in the opposite direction, there is no way to force a page to sent via regular http.

强制页面以纯 http 显示的正确 Rails 3.1 方法是什么?强制 SSL 真的能取代 ssl_requirement 吗?

What is the correct Rails 3.1 way to force a page to be displayed in plain http? Does Force SSL truly supersede ssl_requirement?

推荐答案

Force SSL 的代码非常易于阅读.

The code for Force SSL is pretty easy to read.

https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/force_ssl.rb

它似乎并没有做相反的事情并强制使用 http.它提供了唯一和例外选项来控制哪些操作和控制器需要 SSL,但不提供强制使用 HTTP 而不是 https 的方法.

It doesn't seem to do the reverse and force http to be used. It provides the only and except options to control which actions and controllers SSL is to be required for, but doesn't provide a way to force HTTP to be used instead of https.

这篇关于Rails 3.1 强制使用常规 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆