Skip to content
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

url encoding for arrays #52

Closed
jurrack opened this issue May 7, 2013 · 6 comments
Closed

url encoding for arrays #52

jurrack opened this issue May 7, 2013 · 6 comments

Comments

@jurrack
Copy link

jurrack commented May 7, 2013

Hi,

recently I had some problems with your encoding of arrays in the query params.
While adding an index in the brackets is a nice idea to make sure the array will be sorted correctly. But most it seems to break with the W3C suggestion (http://www.w3.org/TR/url/#collect-the-url-parameters) and implementation in some frameworks.

An option for setting the array encoding would be nice. So you could enable or disable this feature.

Best regards
Steffen

P.S.: Thanks for building Typhoeus.

@hanshasselberg
Copy link
Member

hey @jurrack,

can you describe how you expect them to be serialized? The reason why it is implemented in that way are nested hashes or arrays. Also in case you are working with rails or rack there is something you can do about it: http://rubydoc.info/gems/typhoeus/0.6.3/frames/Rack/Typhoeus/Middleware/ParamsDecoder.

@jurrack
Copy link
Author

jurrack commented May 7, 2013

Hi @i0rek ,

I would expect them to be serialized as :

?my_array[]=1&my_array[]=2&...&my_array[]=n

or

?my_array=1&my_array=2&...&my_array=n

I just overloaded Ethon::Easy::Queryable to my needs.

@hanshasselberg
Copy link
Member

@jurrack You could add a config variable for it and use it to decide what to do. Do you want to take a stab at it?

@ypadlyak
Copy link

ypadlyak commented Jun 7, 2013

Can anyone share a bit more detailed insights on how to implement this?
We have to deal with API, which accepts only "?my_array=1&my_array=2&...&my_array=n" way to pass arrays.

@jurrack Could you please share your code overriding Ethon::Easy::Queryable?

Thank you in advance!

@hanshasselberg
Copy link
Member

It should be as simple as changing this line to:

key = prefix

@hanshasselberg
Copy link
Member

closing for now.

dylanfareed referenced this issue Feb 6, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants