无效请求:无效的HTTP格式,Rails中的解析失败 [英] Invalid request: Invalid HTTP format, parsing fails in Rails

查看:396
本文介绍了无效请求:无效的HTTP格式,Rails中的解析失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在传递具有特殊字符的字符串时,我收到无效请求:无效的HTTP格式,解析失败错误。日志中的错误如下。

While passing a string with special character i am getting Invalid request: Invalid HTTP format, parsing fails error. The error in log as follows.

我的请求:

 http://localhost:3000/search/%

错误日志:

 Invalid request: Invalid HTTP format, parsing fails.
/.rvm/gems/ruby-1.9.3-p545/gems/thin-1.6.2/lib/thin/request.rb:84:in `execute'
/.rvm/gems/ruby-1.9.3-p545/gems/thin-1.6.2/lib/thin/request.rb:84:in `parse'
/.rvm/gems/ruby-1.9.3-p545/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
/.rvm/gems/ruby-1.9.3-p545/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/.rvm/gems/ruby-1.9.3-p545/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/.rvm/gems/ruby-1.9.3-p545/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
/.rvm/gems/ruby-1.9.3-p545/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
/.rvm/gems/ruby-1.9.3-p545/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
/.rvm/gems/ruby-1.9.3-p545/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
/.rvm/gems/ruby-1.9.3-p545/gems/railties-4.0.2/lib/rails/commands/server.rb:84:in `start'
/.rvm/gems/ruby-1.9.3-p545/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
/.rvm/gems/ruby-1.9.3-p545/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
/.rvm/gems/ruby-1.9.3-p545/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

可能是什么问题?请建议我解决此问题。

What could be the problem? Please suggest me an idea to fix this issue.

如何在获得以下错误的同时重定向到另一个页面?

How to redirect to another page while getting below error?

推荐答案

如下更新你的nginx配置文件并在公共文件夹中创建400.html文件。

Update your nginx configuration file as below and create 400.html file in public folder.

server
{
listen 80 ;

server { listen 80;

  root /public;   # <--- be sure to point to 'public'!

error_page 400 /400.html;
location = /400.html {
    internal;
}   

}

这篇关于无效请求:无效的HTTP格式,Rails中的解析失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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