[PATCH] Add autoindex_css_file option

Maxim Dounin mdounin at mdounin.ru
Sun Feb 20 21:24:48 MSK 2011


Hello!

On Sun, Feb 20, 2011 at 06:03:45PM +0100, Clément Bœsch wrote:

> Hi,
> 
> I sent a while ago a patch on nginx mailing list, and recently realized
> it was the wrong place. So I took the time to update and fix the old patch
> for nginx current development version.
> 
> This patch basically adds an autoindex_css_file option in order to allow
> some customizations in the index listing.
> 
> One thing I'm not sure about is the ngx_alloc call; I didn't find any
> ngx_asprintf or such, but maybe there is some quicker/better way to do it.

1. You shouldn't use ngx_alloc() for request-related data.  Using 
ngx_palloc() is much easier and don't require free() (which is 
missed in your patch, btw).

2. There is no need to do any separate allocs in this case, 
changing main one (and relevant output code) in 
ngx_http_autoindex_handler() is enough.

Additionally, I personally believe that using css without making 
sure page will be rendered in standards mode is bad idea.

> Also, I didn't add the prototype declaration since it's a static function;
> should I?

Generally style suggest that handler function should be kept 
first, and static functions are declared.  Following any of these 
rules will require you to add declaration.

Though in this particular case there is no need to add 
function, see above.

Maxim Dounin



More information about the nginx-devel mailing list