Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well.. as i see it, this is a normal behaviour. I'll explain why. If you only have access to a Rack::Request,(i guess that) your middleware does not parse the response (you do not include something like <em>ActionController::ParamsParser</em>), so you don't have access to a hash of parameters, but to a StringIo. This StringIO corresponds to a stream <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2" rel="nofollow noreferrer">like</a>:</p> <pre><code>Content-Type: multipart/form-data; boundary=AaB03x --AaB03x Content-Disposition: form-data; name="param1" value1 --AaB03x Content-Disposition: form-data; name="files"; filename="file1.txt" Content-Type: text/plain ... contents of file1.txt ... --AaB03x-- </code></pre> <p>What you are trying to do with the Net::HTTP class is to: (1). parse the request into a hash of parameters; (2). merge the parameters hash with your own parameters; (3). recreate the request. The problem is that Net::HTTP library can't do (1), since it is a client library, not a server one.</p> <p>Therefore, you can not escape parsing some how your request before adding the new parameters.</p> <p>Possible solutions:</p> <ol> <li><p>Insert ActionController::ParamsParser before your middleware. After that, you may use the excellent <a href="http://rdoc.info/projects/archiloque/rest-client" rel="nofollow noreferrer">rest-client</a> lib to do something like:</p> <p>RestClient.post ('<a href="http://your_server" rel="nofollow noreferrer">http://your_server</a>' + request.path_info), :params => params.merge(your_params)</p></li> <li><p>You can attempt to make a wrapper on the StringIO object, and add, at the end of stream,your own parameters. However, this is not trivial nor advisable. </p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload