Welcome! Log In Create A New Profile

Advanced

Nginx module development question

Posted by VernJensen 
Nginx module development question
March 28, 2014 08:13PM
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?



Edited 1 time(s). Last edit at 03/28/2014 08:14PM by VernJensen.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 91
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready