rails下修改http头(http header)

rails下修改http头(http header)

博客分类: Ruby & Rails
RailsRubyRackExcel
其实就是修改response中一个叫做headers的Hash.
至于header中可以设置什么值,请参考http header的参数.

Ruby代码  收藏代码
# 比如对一个非法的请求进行提示 5 秒后,自动跳转到网站的首页 
response.headers['http-equiv'] = 'refresh' 
response.headers['content'] = "5;#{root_url}" 
render :text => 'Request is invalid' 
 
# 快速地输出电子表格 
response.headers['Content-Type'] = 'application/vnd.ms-excel'   
response.headers['Content-Disposition'] = "attachment;filename=\"ooxx.xls\"" 


修改http头是很少很少的情况下才会做的,备忘.

猜你喜欢

转载自schooltop.iteye.com/blog/2105415