- Iterating through a list within Nginx:
- https://github.com/nginx/nginx/blob/master/src/core/ngx_list.h#L57
Last active
October 14, 2015 00:40
-
-
Save davidjb/4a89dfb3b9df75da1e67 to your computer and use it in GitHub Desktop.
Random hacky snippets for use within Nginx, mostly for debugging purposes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Injecting a header within Nginx core code | |
* ngx_http_request_t *r; is predefined. | |
*/ | |
ngx_table_elt_t *h; | |
h = ngx_list_push(&r->headers_out.headers); | |
if (h == NULL) { | |
return NGX_ERROR; | |
} | |
h->hash = 1; | |
ngx_str_set(&h->key, "Header") | |
ngx_str_set(&h->value, "Value") | |
/* Logging within the debug log | |
* debug1 can be debug0 through debug8, depending on the number of arguments to pass | |
* sprintf formatting can feature %V, for value, %i for integer, etc. | |
* This example logging outputs the fake header as we defined above. | |
*/ | |
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "**** %V: %V", &h->key, &h->value); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment