webmachine/webmachine-ruby

Cookie handling in adapters?

rfestag opened this issue · 0 comments

I ran into an issue trying to update webmachine-test to support cookie sessions (ie, keeping track of all cookies set by the server and automatically responding with them to emulate what browsers do on multi-request tests). I assumed that, at some point in Webmachine's core logic, it would be converting the Set-Cookie header array to a string. It looks like that isn't the case...instead, the adapters appear to handle it as a special case.

Would it be better if set_cookie only worked with strings, and always just concatenated new cookies to the string? Or is there some reason why special handling is done in the adapters (

cookies = [response.headers['Set-Cookie'] || []].flatten
)? I'm happy to work around it in whatever way makes sense, but it seems to me that the values of headers are always strings, and we should probably consistently represent it that way in the core logic, rather than leaving it to adapters to know which headers could be "multi value" and format them correctly.