开发者

Empty parameters hash when doing XML requests. request.content_type is indeed application/xml

开发者 https://www.devze.com 2023-04-10 19:30 出处:网络
My actions are behaving strangely. All requests I do with XML content type (through cURL, ActiveResource, you name it) have empty params[] inside my actions. I d开发者_JAVA技巧ebugged request.content_

My actions are behaving strangely. All requests I do with XML content type (through cURL, ActiveResource, you name it) have empty params[] inside my actions. I d开发者_JAVA技巧ebugged request.content_type and it is application/xml. Debugging request.body.read shows that the XML that I sent in the request is there too.

Interestingly enough, debugging request.formats returns [*/*].

I also tried to add a simple Rack middleware at the beggining of my stack and the CONTENT_TYPE is right there in my env variable, with it's correct value.

With this problem, my request body never gets parsed and I always get into the format.html block of my respond_to call.

I inspected ActionDispatch::ParamsParser and the params are being built correctly there and placed into env["action_dispatch.request.request_parameters"]. However they end up as an empty params[] in my actions (just for non HTML requests, i.e. JSON, XML, etc).

Any ideas of what can be wrong? Thanks!

In the meantime, I found a solution myself: It was some strange combination of memcache-client being used for session store in my app. It worked on my co-worker Ubuntu box. I replaced memcache-client with dalli and changed the session store to configuration to explicitely set the memcache server host as the localhost. It worked.


Check this gem: actionpack-xml_parser. I think this gem will resolve your query because I had the same issue it was able to resolve it with this.

0

精彩评论

暂无评论...
验证码 换一张
取 消