'EOFError:达到文件结束'在通过SSL发布UTF-8时在HEROKU上 [英] 'EOFError: end of file reached' on HEROKU while posting UTF-8 via SSL

查看:112
本文介绍了'EOFError:达到文件结束'在通过SSL发布UTF-8时在HEROKU上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在heroku上有个奇怪的bug。要重现它,我必须在请求正文中使用任何UTF-8字符创建大(超过几KB)的HTTPS POST。这里是一个例子:

  requirenet / https
需要uri

#Accutally我发现了这个错误,而张贴到另一台服务器
url = URI.parse(https://api.heroku.com/myapps)

#这是乌克兰' 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请求}

在本地计算机的irb上运行这样的脚本给了我:

 #< Net :: HTTPUnauthorized 401 Unauthorized readbody = true> 

...这是预期的,但在heroku雪松上,在'heroku console'上运行它。 。在大约60秒内,我得到:

  EOFError:文件结尾从/ 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:在`readuntil'中
从/usr/local/lib/ruby/1.9.1/net/protocol.rb:126:in`readline'
从/ 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:在`request'中
从(irb):32:在`block in irb_binding'
from /usr/local/lib/ruby/1.9.1/ne t / http.rb:627:在'start'中
从(irb):32
从/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/ rails / commands / console.rb:47:在`start'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/commands/console.rb: 8:在`start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.7/lib/rails/commands.rb:41:in`< top(required) >'

我该怎么处理它?<​​b>

Gemfile 中。

  source'https://rubygems.org'
ruby​​1.9.3

gem'rails','3.2.7'
gem'pg'
...


I've got strange bug on heroku. To reproduce it I have to make big (over few KB) HTTPS POST with any UTF-8 characters in request body. Here is an example:

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 }

Running such script on local machine's irb gives me:

#<Net::HTTPUnauthorized 401 Unauthorized readbody=true> 

...which is expected, but on heroku cedar, runing it on 'heroku console' ... in about 60sec I get:

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)>'

What should I do with it?

解决方案

I had to add ruby version into Gemfile, as default Cedar's ruby is 1.9.2(which has bug passing UTF-8 strings over SSL)

source 'https://rubygems.org'
ruby "1.9.3"

gem 'rails', '3.2.7'
gem 'pg'
...

这篇关于'EOFError:达到文件结束'在通过SSL发布UTF-8时在HEROKU上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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