Ruby 如何阻止sinatra重新写入标题名?

Ruby 如何阻止sinatra重新写入标题名?,ruby,http-headers,sinatra,rack,p3p,Ruby,Http Headers,Sinatra,Rack,P3p,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['DATABAS

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 test
get '/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 #0
SUCCESS
我如何阻止sinatra重新编写cookie名称。我能做一个猴子补丁吗?

,所以理论上这不应该是个问题–
P3p
应该和
P3p
一样有效

在您的情况下,标题是,而不是Sinatra。更改到另一台服务器,如Thin(它不会更改头)将是最简单的修复方法(使用Thin over Webrick还有其他好处)

如果您真的需要继续使用Webrick,您可以考虑进行修补。您必须小心,因为Webrick会将标题名称降级以处理重复的标题,所以您可能必须对此进行说明

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)