ncr / rack-proxy

A request/response rewriting HTTP proxy. A Rack app.
MIT License
269 stars 94 forks source link

Treat header values as arrays #11

Closed ntalbott closed 11 years ago

ntalbott commented 11 years ago

This fixes the case of multiple headers of the same name (set-cookie being the real world example I ran into) getting all smooshed together into a single (invalid) header. Net::HTTP tries to be smart and join such headers with a ", ", which isn't so bad when immediately consuming the results, but wreaks havoc when passing those headers through the proxy.

Treating the header values as arrays fixes this issue, as Rack happily does the right thing and passes back a separate header for each value it sees in the array.

This definitely has the potential for breakage, as it implicitly changes the header portion of the triplet passed to #rewrite_response.

I tried to figure out how to write a test for this and came up empty. Best bet is probably to have your trix.pl endpoint return a double header and verify that rack-proxy does the right thing with it.

ncr commented 11 years ago

Thanks!

chikamichi commented 11 years ago

@ntalbott nice blog post ;)