请求无效:HTTP格式无效,解析失败

bud*_*kin 20 ruby-on-rails

我经常在rails服务器日志中收到此错误:

Invalid request: Invalid HTTP format, parsing fails.
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/thin-1.6.1/lib/thin/request.rb:84:in `execute'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/thin-1.6.1/lib/thin/request.rb:84:in `parse'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/thin-1.6.1/lib/thin/connection.rb:41:in `receive_data'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/faye-websocket-0.7.2/lib/faye/adapters/thin.rb:44:in `receive_data'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/thin-1.6.1/lib/thin/backends/base.rb:73:in `start'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/thin-1.6.1/lib/thin/server.rb:162:in `start'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/railties-4.0.1/lib/rails/commands/server.rb:84:in `start'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/railties-4.0.1/lib/rails/commands.rb:76:in `block in <top (required)>'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/railties-4.0.1/lib/rails/commands.rb:71:in `tap'
    /home/budkin/gamestown/vendor/cache/ruby/2.0.0/gems/railties-4.0.1/lib/rails/commands.rb:71:in `<top (required)>'
    bin/rails:4:in `require'
    bin/rails:4:in `<main>'
Run Code Online (Sandbox Code Playgroud)

一切正常,但错误只是令人讨厌

是的,这是开启的 thin

小智 13

我有与上面完全相同的错误.在我的情况下,它是一个(.net)客户端尝试使用HTTPS而不是HTTP连接到我的(瘦)服务器.一旦我将协议更改回基本http,错误就消失了.


小智 8

与瘦服务器有同样的问题.

我在thin的request.rb文件中抛出了binding.pry,发现以下请求导致错误:"GET/info?txtAirPlay&txtRAOP RTSP/1.0\r \n\r \n"

事实证明,这可能是Yosemite(我正在运行10.10.3)和您正在运行的localhost端口的问题.我在端口5000上运行,如果你看下面的堆栈溢出帖子,你会看到Apple AirTunes在端口5000上运行: AirPlay搞砸了localhost

尝试更改rails服务器端口以消除错误(我只是随机选择了5212):

rails s -p 5212


sur*_*ntt 6

我在rails s -e production的调试会话期间访问了https:// localhost:3000,其中config.force_ssl = true.

这迫使最新版本的chrome只尝试访问https:// localhost:3000.com,即使我特意输入了http:// localhost:3000.

如果您的应用程序在隐身模式或其他浏览器中工作.我建议您清除浏览历史记录.

在瘦服务器中绑定.pry之后.我收到的@data加密:

0\tlocalhost\x00\x17\x00\x00\x00#\x00\x00\x00\r\x00\x12\x00\x10\x06\x01\x06\x03\x05\x01\x05\x03\x04\x01\x04\x03\x02\x01\x02\x03\x00\x05\x00\x05\x01\x00\x00\x00\x00\x00\x12\x00\x00\x00\x10\x00\x0E\x00\f\x02h2\bhttp/1.1uP\x00\x00\x00\v\x00\x02\x01\x00\x00\n\x00\b\x00\x06\x00\x1D\x00\x17\x00\x18
Run Code Online (Sandbox Code Playgroud)