Reputation: 91
I would like to pass an array through a http header.
Would it be acceptable to name multiple params the same name, and that way I would know that they belong to an array just like in a get request query string? Example:
CurrentHeaderArray: myarray[]=value1&myarray[]=value2&myarray[]=value3
There is already a stackoverflow answer to pass it through the query string of a get request, see this hyper link. How to pass an array within a query string?
Upvotes: 6
Views: 27835
Reputation: 1101
You can pass an array as string with some delimiter char as the way csv file does. Then, in the server side code, just use some string split function to get back the array. If the string contains the delimiter charater, escapes them.
Upvotes: 5
Reputation: 1530
You can pass an array as a header like this:
CurrentHeaderArray : [ "value1", "value2", "value3" ]
You can easily try this in a tool like Fiddler, using the Composer.
Upvotes: 0