我在 heroku 上遇到了奇怪的错误。为了重现它,我必须使用请求正文中的任何 UTF-8 字符制作大的(超过几 KB)HTTPS POST。这是一个例子:
require "net/https"
require "uri"
#Accutally I've ecountered this bug while posting to another server
url = URI.parse("https://api.heroku.com/myapps")
#It's Ukrainian 'oiced velar plosive G' letter
payload = "ґ"*10000
request = Net::HTTP::Post.new(url.path)
request.body = payload
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.read_timeout = 500
http.start {|http| http.request request }
在本地计算机的 irb 上运行这样的脚本给我:
#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
...这是预期的,但是在 Heroku cedar 上,在“heroku 控制台”上运行它...大约 60 秒我得到:
EOFError: end of file reached
from /usr/local/lib/ruby/1.9.1/openssl/buffering.rb:145:in `sysread_nonblock'
from /usr/local/lib/ruby/1.9.1/openssl/buffering.rb:145:in `read_nonblock'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:135:in `rbuf_fill'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from /usr/local/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from /usr/local/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from /usr/local/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from (irb):32:in `block in irb_binding'
from /usr/local/lib/ruby/1.9.1/net/http.rb:627:in `start'
from (irb):32
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/commands.rb:41:in `<top (required)>'
我应该用它做什么?
我必须将 ruby 版本添加到Gemfile,默认 Cedar 的 ruby 是 1.9.2(在通过 SSL 传递 UTF-8 字符串时存在错误)
source 'https://rubygems.org'
ruby "1.9.3"
gem 'rails', '3.2.7'
gem 'pg'
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)