发布请求参数在 Rails 4.2.2 中被截断,内容类型为“Application/xml"; [英] Post request parameters getting truncated in Rails 4.2.2 with content type as "Application/xml"
问题描述
我有以下观察:
我部署了一个示例 Rails 4.2.2 应用程序,其中包含一个控制器和用于接收 POST 请求的操作.
I deployed a sample Rails 4.2.2 application with a controller and action to receive a POST request.
现在如果我向这个应用程序发送一个带有一些 POST 主体的 POST 请求,请说一个像 {"1"=>"hello","2"=>"bye"}
和如果请求的内容类型是 "application/xml"
,我的 Rails 应用程序中没有收到任何参数.
Now If I send a POST request to this application with some POST body say a hash like {"1"=>"hello","2"=>"bye"}
and if the content type of the request is "application/xml"
, I don't receive any parameters in my Rails app.
如果我将同一请求的内容类型更改为其他内容,我将正确获取参数.
If I change content type of the same request to some thing else , I will get the parameters properly.
有人可以通过 POST 告诉我为什么 Rails 4.2.2 中存在这种行为请求内容类型为 "application/xml"
.
推荐答案
自动解析 XML 主体在 rails 4.0 中被移除并提取到 宝石
Automatic parsing of XML bodies was removed in rails 4.0 and extracted into a gem
即使使用该 gem,您的请求正文也不是有效的 XML.
Even with that gem your request body isn't valid XML.
这篇关于发布请求参数在 Rails 4.2.2 中被截断,内容类型为“Application/xml";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!