Byteranges, not bytesets
1 parent d13faf2 commit f745cc89b3cfc2724445de0b42dfa795386b5e06
@Andreas Jaggi Andreas Jaggi authored on 9 Sep 2011
x-way committed on 9 Sep 2011
Showing 2 changed files
View
2
■■■
README
inspect_headers_log_uninspected on;
inspect_headers_block_violations on;
 
# only allow 3 range definitions in Range header
inspect_headers_range_max_bytesets 3;
inspect_headers_range_max_byteranges 3;
}
 
Limitations
Currently only inspects the following headers: Range, If-Range,
View
14
ngx_http_header_inspect.c
ngx_flag_t log;
ngx_flag_t log_uninspected;
ngx_flag_t block;
 
ngx_uint_t range_max_bytesets;
ngx_uint_t range_max_byteranges;
} ngx_header_inspect_loc_conf_t;
 
 
 
offsetof(ngx_header_inspect_loc_conf_t, log_uninspected),
NULL
},
{
ngx_string("inspect_headers_range_max_bytesets"),
ngx_string("inspect_headers_range_max_byteranges"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_header_inspect_loc_conf_t, range_max_bytesets),
offsetof(ngx_header_inspect_loc_conf_t, range_max_byteranges),
NULL
},
ngx_null_command
};
}
rc = NGX_ERROR;
}
 
if (setcount > conf->range_max_bytesets) {
if (setcount > conf->range_max_byteranges) {
if ( conf->log ) {
ngx_log_error(NGX_LOG_ALERT, log, 0, "header_inspect: Range header contains more than %d bytesets", conf->range_max_bytesets);
ngx_log_error(NGX_LOG_ALERT, log, 0, "header_inspect: Range header contains more than %d byteranges", conf->range_max_byteranges);
}
return NGX_ERROR;
break;
}
conf->log = NGX_CONF_UNSET;
conf->block = NGX_CONF_UNSET;
conf->log_uninspected = NGX_CONF_UNSET;
 
conf->range_max_bytesets = NGX_CONF_UNSET_UINT;
conf->range_max_byteranges = NGX_CONF_UNSET_UINT;
 
return conf;
}
 
ngx_conf_merge_off_value(conf->log, prev->log, 1);
ngx_conf_merge_off_value(conf->block, prev->block, 0);
ngx_conf_merge_off_value(conf->log_uninspected, prev->log_uninspected, 0);
 
ngx_conf_merge_uint_value(conf->range_max_bytesets, prev->range_max_bytesets, 5);
ngx_conf_merge_uint_value(conf->range_max_byteranges, prev->range_max_byteranges, 5);
 
return NGX_CONF_OK;
}