【问题标题】:Excon Error :: BadRequestExcon 错误 :: BadRequest
【发布时间】:2015-04-21 18:18:23
【问题描述】:

有人知道这个错误是从哪里来的吗?我是 AWS 的新手,相信它可能来自那里吗?

Excon::Errors::BadRequest in UsersController#update Expected(200) 实际(400 错误请求) excon.error.response :body => "\nIncompleteBodyThe 请求正文已终止 意外9C1EC55648FB3ED91vv/2RNBp9egndYkTjzbCBgQu0jk3AjpAZffR+firWM4Yzd6ilQxJnfKwKZVK8+N" :headers => { "Connection" => "close" "Content-Type" => “应用程序/xml”“日期”=>“2015 年 4 月 21 日星期二 18:13:09 GMT”“服务器” => "AmazonS3" "x-amz-id-2" => "1vv/2RNBp9egndYkTjzbCBgQu0jk3AjpAZffR+firWM4Yzd6ilQxJnfKwKZVK8+N" "x-amz-request-id" => "9C1EC55648FB3ED9" } :local_address => “10.151.101.107”:local_port => 51335:reason_phrase =>“错误请求” :remote_ip => "54.231.232.1" :status => 400 :status_line => "HTTP/1.1 400 错误请求\r\n"

这是我的用户控制器:

class UsersController < ApplicationController
   before_action :authenticate_user!

   def update
     if current_user.update_attributes(user_params)
       flash[:notice] = "User information updated"
       redirect_to edit_user_registration_path
     else
       flash[:error] = "Invalid user information"
       redirect_to edit_user_registration_path
     end
   end

   private
   def user_params
     params.require(:user).permit(:name, :avatar)
   end
 end

【问题讨论】:

  • 您应该提供有关相应控制器方法的更多信息。

标签: ruby-on-rails


【解决方案1】:

这也可能发生,我通过指向错误的区域发现。我不小心被指向 us-west-2,但我的 S3 存储桶是 us-east-1。我改变了我的雾设置,现在事情变得更快乐了。把这个留在这里希望能帮助别人。

【讨论】:

    【解决方案2】:

    您的 POST 中的正文格式不正确。检查您在正文中传递的数据。您是否在换行符\n 中传递?如果是这样,请务必正确编码。

    【讨论】:

      【解决方案3】:

      我不确定这是否是这个特定问题的原因,但“IncompleteBody”有时可能是由于 Excon 对请求进行了分块,在某些情况下这似乎会终止 S3 连接。

      尝试使用以下代码添加初始化程序:

      if ENV["RAILS_GROUPS"] == 'assets'
        Excon.defaults[:nonblock] = false
      end
      

      来源:Handling S3 IncompleteBody error when using asset_sync gem

      【讨论】:

        猜你喜欢
        • 2015-03-20
        • 1970-01-01
        • 1970-01-01
        • 2020-01-20
        • 1970-01-01
        • 2013-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多