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

Treat header values as arrays #11

Merged
merged 1 commit into from Mar 4, 2013

Conversation

Projects
None yet
3 participants
@ntalbott
Contributor

ntalbott commented Mar 4, 2013

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.

Treat header values as arrays
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 added a commit that referenced this pull request Mar 4, 2013

Merge pull request #11 from ntalbott/headers-fix
Treat header values as arrays

@ncr ncr merged commit e6e2c3a into ncr:master Mar 4, 2013

@ncr

This comment has been minimized.

Show comment
Hide comment
@ncr

ncr Mar 4, 2013

Owner

Thanks!

Owner

ncr commented Mar 4, 2013

Thanks!

@chikamichi

This comment has been minimized.

Show comment
Hide comment
@chikamichi

chikamichi Mar 14, 2013

@ntalbott nice blog post ;)

chikamichi commented Mar 14, 2013

@ntalbott nice blog post ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment