-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to enable Rack-like encoding of array parameters #104
Add option to enable Rack-like encoding of array parameters #104
Conversation
# This is called here to have the side effect of removing | ||
# the :array_encoding key from options, to avoid forwarding | ||
# it to Curl later. FIXME. | ||
array_encoding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed a bit hacky. Could you explicitly remove it in a separate step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about the name params_encoding
for the option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll gladly refactor the Actionable initialization.
params_encoding
looks good to me. Even though it only affects arrays, for now, it's more explanatory and forward-looking.
@i0rek all done. 😺 |
Thank you very much for your work @vjt! |
Add option to enable Rack-like encoding of array parameters
Thanks for the merge, @i0rek! My pleasure. |
Thanks @vjt for this fix :) This is exactly what I needed in my app. |
Been tracking this for a while, trying to get rid of a fork in our code, related links: #52 |
typhoeus/typhoeus#320 We were seeing array params tranformed into the following: /event?groups[0]=open-forum&groups[1]=armory-films but we need the client to send array params to various API services in the following (valid) format: /event?groups[]=open-forum&groups[]=armory-films
Rack applications expect
to be encoded as:
whilst Ethon by default encodes it as:
This patch adds an
array_encoding
option toEthon::Easy
. If it set to:rack
, then arrays are encoded the Rack way, both inparams: {}
and inbody: {}
. Any other value retains the current behaviour.The option can be forwarded directly from
Typhoeus::Request.new
.This implements typhoeus/typhoeus#424.