Skip to content

Enable proxy response to have multiple Set-Cookie raw headers #1101#1102

Closed
kriswill wants to merge 1 commit intohttp-party:masterfrom
kriswill:raw-headers-set-cookie
Closed

Enable proxy response to have multiple Set-Cookie raw headers #1101#1102
kriswill wants to merge 1 commit intohttp-party:masterfrom
kriswill:raw-headers-set-cookie

Conversation

@kriswill
Copy link
Copy Markdown
Contributor

@kriswill kriswill commented Dec 4, 2016

Implementation of proxy HTTP raw headers response processing in 1.16.0 fails to account for multiple Set-Cookie headers. This patch accounts for multiple Set-Cookie header, and sets the source response headers to an array.

Copy link
Copy Markdown
Contributor

@jcrugzz jcrugzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are for the future as I will take care of this and push it out since it is broken for this case currently. Thanks for this!

// message.rawHeaders is added in: v0.11.6
// https://nodejs.org/api/http.html#http_message_rawheaders
if (proxyRes.rawHeaders != undefined) {
if (proxyRes.rawHeaders !== undefined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code here supports if it is undefined or null, we should be sure that it is strictly undefined.

var rewriteCookieDomainConfig = options.cookieDomainRewrite,
// In proxyRes.rawHeaders Set-Cookie headers are sparse.
// so, we'll collect Set-Cookie headers, and set them in the response as an array.
set_cookies = [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

if (header != undefined) {
if (rewriteCookieDomainConfig && key.toLowerCase() === 'set-cookie') {
header = common.rewriteCookieDomain(header, rewriteCookieDomainConfig);
if (key === 'Set-Cookie' || key === 'set-cookie') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can still do key.toLowerCase() === 'set-cookie'

@jcrugzz
Copy link
Copy Markdown
Contributor

jcrugzz commented Dec 4, 2016

cherry-picked, thanks!

@jcrugzz jcrugzz closed this Dec 4, 2016
@pachirel
Copy link
Copy Markdown
Contributor

pachirel commented Dec 6, 2016

@kriswill Thanks to fix this issue. and sorry for any inconvenience.

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

Successfully merging this pull request may close these issues.

3 participants