Welcome! Log In Create A New Profile

Advanced

Re: ngx_http_process_header_line function in source code

Maxim Dounin
June 16, 2014 07:32AM
Hello!

On Sun, Jun 15, 2014 at 06:03:27PM -0400, alayim wrote:

> Hi,
> I'm browsing through the source code of the project, and looked at
> ngx_http_request.c where the function ngx_http_process_header_line() creates
> a pointer to a pointer to a large struct(ngx_http_request_t) containing a
> smaller one(ngx_http_headers_in_t), containing yet another one.
>
> ngx_http_process_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
> ngx_uint_t offset) {
> ph = (ngx_table_elt_t **) ((char *) &r->headers_in + offset);
> // ... then check if ph is NULL, and if so point it to h
> }
>
>
> Why is it done in this way? It seems quite complex and error prone, doesen't
> it?
> Is there any reason something like this wasn't done instead?
>
> (where range are ONE of those structures in headers_in that are a
> ngx_table_elt_t)
> if(r->headers_in->range == NULL) {
> r->headers_in->range = h;
> }

The ngx_http_process_header_line() function is used to handle lots
of header lines. You can't hardcode just one name into it -
you'll have to write 15 functions instead (and add another one on
each header line added). Using one universal function instead
greatly reduces code size and therefore less error prone.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx_http_process_header_line function in source code

alayim June 15, 2014 06:03PM

Re: ngx_http_process_header_line function in source code

Maxim Dounin June 16, 2014 07:32AM

Re: ngx_http_process_header_line function in source code

alayim June 21, 2014 10:35AM

Re: ngx_http_process_header_line function in source code

alayim June 21, 2014 10:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready