HTTP 解析错误,格式错误的请求 - Ruby on Rails [英] HTTP parse error, malformed request - Ruby on Rails

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

问题描述

我在尝试运行 Ruby on Rails 应用程序时在终端中看到以下错误.

I see the following error in Terminal when attempting to run a Ruby on Rails app.

HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2017-03-12 13:10:02 -0400: ENV: {"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}

浏览器错误:

This site can’t provide a secure connection. localhost sent an invalid response. ERR_SSL_PROTOCOL_ERROR*

我已经尝试了以下

  • 清除浏览器缓存并重新启动
  • 恢复到当时正在运行的 GIT 中的旧提交
  • 重启终端
  • 运行另一个功能正常的 Rails 应用

推荐答案

这里有一些可能的解决方案.

Here are some possible solutions.

  1. 确保您通过 http://localhost:3000 而不是 https://localhost:3000.

如果浏览器重定向到 HTTPS 并且是 Google Chrome,请尝试以下解决 HSTS 问题的解决方案:https://stackoverflow.com/a/28586593

If the browser redirects to HTTPS and it's Google Chrome, try this solution that addresses an HSTS problem: https://stackoverflow.com/a/28586593

确保您没有强制使用 HTTPS 的生产环境(如果这就是您所服务的环境).如果这是问题所在,请将其注释掉或将 true 更改为 false:

Make sure you do not have the production environment (if that's what you're serving) forcing HTTPS. If that's the problem, comment this out or change true to false:

config/environments/production.rb

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true

这篇关于HTTP 解析错误,格式错误的请求 - Ruby on Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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