HTTP 解析错误,格式错误的请求

编程入门 行业动态 更新时间:2024-10-28 19:25:07
本文介绍了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.

  • 确保您通过 localhost:3000 而不是 进行连接://localhost:3000" rel="noreferrer">localhost:3000.

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

    If the browser redirects to HTTPS and it's Google Chrome, try this solution that addresses an HSTS problem: stackoverflow/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 解析错误,格式错误的请求

    本文发布于:2023-10-27 06:42:28,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1532614.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:错误   格式   HTTP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!