简体   繁体   English

通过SSL发布UTF-8时,在HEROKU上出现“ EOFError:文件已到达结尾”

[英]'EOFError: end of file reached' on HEROKU while posting UTF-8 via SSL

I've got strange bug on heroku. 我在heroku上有一个奇怪的错误。 To reproduce it I have to make big (over few KB) HTTPS POST with any UTF-8 characters in request body. 要重现它,我必须使用请求主体中的任何UTF-8字符来制作大型(超过几个KB)的HTTPS POST。 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: 在本地计算机的irb上运行这样的脚本会给我:

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

...which is expected, but on heroku cedar, runing it on 'heroku console' ... in about 60sec I get: ...这是预期的,但是在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)>'

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) 我必须将宝石版本添加到Gemfile中 ,因为默认Cedar的宝石是1.9.2(通过SSL传递UTF-8字符串存在错误)

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

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

I think, this should works: 我认为,这应该可行:

require "net/https"
require "uri"

url = URI.parse("https://api.heroku.com/myapps")
#It's Ukrainian letter 'soft-G'
payload = "ґ"*10000
request = Net::HTTP::Post.new(url.path)
request.basic_auth 'youremail', 'yourpassword'
request.body = URI.encode(payload)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.read_timeout = 500
http.start {|http| http.request request }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 文件结尾达到EOFError(Databasedotcom + Rails + Heroku) - end of file reached EOFError (Databasedotcom + Rails + Heroku) EOFError:文件结尾达到错误,然后在Heroku中与工作程序发生内存错误 - EOFError: end of file reached error and then memory error on heroku with workers DelayedJobAdapter 因 EOFError 失败:已到达文件结尾 - DelayedJobAdapter fails with EOFError: end of file reached EOFError:文件结尾与Net :: HTTP达成问题 - EOFError: end of file reached issue with Net::HTTP savon HTTPI POST EOFError:已到达文件末尾 - savon HTTPI POST EOFError: end of file reached EOFError:通过Savon ruby​​客户端调用SOAP API的文件末尾 - EOFError: end of file reached calling a SOAP API via Savon ruby client Ruby on Rails 中带有 http.request 的 EOFError(到达文件末尾) - EOFError (end of file reached) in Ruby on Rails with http.request EOFError - 使用 Zoho 邮件时到达文件末尾 - EOFError - end of file reached when using Zoho mail Rails 4:EOFError:仅在开发中的任何电子邮件后到达文件结尾 - Rails 4: EOFError: end of file reached following any email in DEVELOPMENT only 保存设计用户时,Rails EOFError(到达文件末尾) - Rails EOFError (end of file reached) when saving a devise user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM