-
Notifications
You must be signed in to change notification settings - Fork 2k
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
bugfix: wip: Set headers in the tail of a list rather than in the head #2182
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,62 +319,40 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r, | |
|
||
headers = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset); | ||
|
||
if (hv->no_override) { | ||
for (h = *headers; h; h = h->next) { | ||
if (!h->hash) { | ||
h->value = *value; | ||
h->hash = hv->hash; | ||
return NGX_OK; | ||
} | ||
} | ||
|
||
goto create; | ||
} | ||
|
||
/* override old values (if any) */ | ||
|
||
if (*headers) { | ||
for (h = (*headers)->next; h; h = h->next) { | ||
for (h = *headers; h; h = h->next) { | ||
if (!hv->no_override) { | ||
h->hash = 0; | ||
h->value.len = 0; | ||
} | ||
} | ||
|
||
h = *headers; | ||
|
||
if (h->hash == 0) { | ||
// update the last element if possible | ||
h->value = *value; | ||
|
||
if (value->len == 0) { | ||
h->hash = 0; | ||
|
||
} else { | ||
if (value->len != 0) { | ||
h->hash = hv->hash; | ||
} | ||
|
||
return NGX_OK; | ||
} | ||
|
||
create: | ||
|
||
for (ph = headers; *ph; ph = &(*ph)->next) { /* void */ } | ||
} else { | ||
ho = ngx_list_push(&r->headers_out.headers); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when last element is valid and other elements are not, here will make a new element, right? Does it mean that the invalid elements never be reused in pool? So why not just nullifying the first element There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually when set builtin multi input header, it just nullifying the next pointer. can we do same thing for output headers? |
||
if (ho == NULL) { | ||
return NGX_ERROR; | ||
} | ||
|
||
ho = ngx_list_push(&r->headers_out.headers); | ||
if (ho == NULL) { | ||
return NGX_ERROR; | ||
} | ||
ho->value = *value; | ||
|
||
ho->value = *value; | ||
if (value->len == 0) { | ||
ho->hash = 0; | ||
|
||
if (value->len == 0) { | ||
ho->hash = 0; | ||
} else { | ||
ho->hash = hv->hash; | ||
} | ||
|
||
} else { | ||
ho->hash = hv->hash; | ||
ho->key = hv->key; | ||
ho->next = NULL; | ||
h->next = ho; | ||
} | ||
|
||
ho->key = hv->key; | ||
ho->next = NULL; | ||
*ph = ho; | ||
|
||
return NGX_OK; | ||
#else | ||
ngx_array_t *pa; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, I'm afraid here
h
is NULL ptr after last for loop iterate...