ruby – 如何阻止sinatra重写我的标题名称?

ruby – 如何阻止sinatra重写我的标题名称?,第1张

概述Sinatra是所有标题名称的骆驼套管,导致’P3P’出现问题.码: require 'rubygems'require 'sinatra'configure :production do # Configure stuff here you'll want to # only be run at Heroku at boot # TIP: You can get you d Sinatra是所有标题名称的骆驼套管,导致’P3P’出现问题.码:

require 'rubygems'require 'sinatra'configure :production do  # Configure stuff here you'll want to  # only be run at Heroku at boot  # TIP:  You can get you database information  #       from ENV['DATABASE_URI'] (see /env route below) end# Quick testget '/track' do  #response.headers['Cache-Control'] = 'public,max-age=300'  response.set_cookie("visited",1)  response['this-that'] = "CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\""  response['P3P'] = "CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\""  "SUCCESS"end

给我吗

* About to connect() to localhost port 9393 (#0)*   Trying 127.0.0.1... connected> GET /track http/1.1> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libIDn/1.23 librtmp/2.3> Host: localhost:9393> Accept: */*> < http/1.1 200 OK < x-frame-options: sameorigin< X-Xss-Protection: 1; mode=block< Content-Type: text/HTML;charset=utf-8< This-That: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"< P3p: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"< Content-Length: 7< Server: WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20)< Date: Sun,28 Oct 2012 16:26:47 GMT< Connection: Keep-Alive< Set-cookie: visited=1< * Connection #0 to host localhost left intact* Closing connection #0SUCCESS

正如你所看到的那样 – 被重写为This-That并且P3P被重写为P3p.这是我的宝石清单:

*本地宝石*

addressable (2.3.2)bundler (1.2.1)excon (0.16.7)heroku (2.32.14)heroku-API (0.3.5)launchy (2.1.2)mime-types (1.19)netrc (0.7.7)rack (1.4.1)rack-protection (1.2.0)rake (0.9.2.2)rest-clIEnt (1.6.7)rubygems-bundler (1.1.0)rubyzip (0.9.9)rvm (1.11.3.5)shotgun (0.9)sinatra (1.3.3)tilt (1.3.3)

如何阻止sinatra重写cookie名称.我能做一个猴子补丁吗?

解决方法 HTTP header names should be case insensitive,所以理论上这应该不是问题 – P3p应该和P3P一样好用.

在你的情况下,标题是altered by the Webrick server,而不是Sinatra.更改为另一个服务器(如Thin(不会更改标头))将是最简单的修复(使用Thin over Webrick还有其他好处).

如果你真的需要继续使用Webrick,你可以考虑修补WEBrick::HTTPResponse.你必须要小心,因为Webrick会对标题名称进行下调以处理重复项,因此你可能需要考虑到这一点.

总结

以上是内存溢出为你收集整理的ruby – 如何阻止sinatra重写我的标题名称?全部内容,希望文章能够帮你解决ruby – 如何阻止sinatra重写我的标题名称?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1293935.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存