{"comment":{"url":"https://api.github.com/repos/davidhanley/repsheet-nginx/comments/14079122","html_url":"https://github.com/davidhanley/repsheet-nginx/commit/c4ec158f617229e277ecf546d32a5a3d1939c818#commitcomment-14079122","id":14079122,"user":{"login":"prokopowicz","id":6181084,"avatar_url":"https://avatars.githubusercontent.com/u/6181084?v=3","gravatar_id":"","url":"https://api.github.com/users/prokopowicz","html_url":"https://github.com/prokopowicz","followers_url":"https://api.github.com/users/prokopowicz/followers","following_url":"https://api.github.com/users/prokopowicz/following{/other_user}","gists_url":"https://api.github.com/users/prokopowicz/gists{/gist_id}","starred_url":"https://api.github.com/users/prokopowicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prokopowicz/subscriptions","organizations_url":"https://api.github.com/users/prokopowicz/orgs","repos_url":"https://api.github.com/users/prokopowicz/repos","events_url":"https://api.github.com/users/prokopowicz/events{/privacy}","received_events_url":"https://api.github.com/users/prokopowicz/received_events","type":"User","site_admin":false},"position":44,"line":176,"path":"ngx_http_repsheet_module.c","commit_id":"c4ec158f617229e277ecf546d32a5a3d1939c818","created_at":"2015-10-29T21:15:51Z","updated_at":"2015-10-29T21:15:51Z","body":"The ngx_str_set_func does what you describe - setting the values directly into ngx_str_t.data and .len.   The existing nginx macro ngx_str_set doesn't support anything but string literals because of how it uses sizeof instead of strlen.\r\n\r\nThe extra step of copying the header value into the static memory solves the problem of the life-cycle of the value bytes.  For example, if the value bytes are allocated on the stack of some function as a local char buffer[100], and you set ngx_str_t.data to this pointer, it will be invalid when the function exits.  So we made a place to keep the value indefinitely until it is overwritten.  Of course, not thread safe, but nothing in this code is.  "}}