RoR: POST to the page using raw form data. How?

Is there a ruby โ€‹โ€‹method for POST form data encoded in "x-www-form-urlencoded" as stated here? http://www.w3.org/MarkUp/html-spec/html-spec_8.html

I am aware of Net :: HTTP.post_form, but since I have multiple publishing values โ€‹โ€‹that have the same name, I cannot use the hash that is required for this method.

To clarify, I have a line of the form "value1 = x & value1 = y & value1 = z & value2 = a & value3 = b" and I want it to be able to send POST to another page. How can i do this?

+3
source share
2 answers

I think internally the params object is the parsed version of the actual original message body in the HTTP request. All mail data is published the same way (as raw data), but the params hash in ActionController has already analyzed this into an easy-to-use hash. If you really need the source data from the form, you can access it through the raw_post method of the request object itself.

The documentation for ActionController :: Request.raw_post is here for rails3, but has been available since at least 2.3.8 (the only version 2.3. X version I checked). I think it was likely to be available longer.

In the controller, try self.request.raw_postto get the raw data as a string.

+1
source

, ? , , .

0

Source: https://habr.com/ru/post/1771974/


All Articles