Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Nginx module development question

$
0
0
I'm starting to get my feet wet with nginx module development. I've looked over Evan Miller's guide, as well as a few articles on nginxguts.com, and have plugged in one of the Hello World examples (from yet another site) and it works fine.

So for my question: in the handler, the Hello World examples set the Content Type using:

r->headers_out.content_type_len = sizeof("text/html") - 1;
r->headers_out.content_type.len = sizeof("text/html") - 1;
r->headers_out.content_type.data = (u_char *) "text/html";

I'm wondering, if I were to use a dynamically allocated C string (using calloc) instead of the static "text/html", would it be safe to release this string after calling

rc = ngx_http_send_header(r);

near the end of my handler? Or is this field possibly used at some later point, even after you call ngx_http_send_header?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>