mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 23:49:00 +08:00
ngx_http_arg()
This commit is contained in:
parent
ed9b6d8962
commit
84d17bba65
@ -60,12 +60,12 @@ ngx_module_t ngx_http_flv_module = {
|
||||
static ngx_int_t
|
||||
ngx_http_flv_handler(ngx_http_request_t *r)
|
||||
{
|
||||
u_char *p, *n, *last;
|
||||
u_char *last;
|
||||
off_t start, len;
|
||||
size_t root;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t level, i;
|
||||
ngx_str_t path;
|
||||
ngx_str_t path, value;
|
||||
ngx_log_t *log;
|
||||
ngx_buf_t *b;
|
||||
ngx_chain_t out[2];
|
||||
@ -167,18 +167,10 @@ ngx_http_flv_handler(ngx_http_request_t *r)
|
||||
i = 1;
|
||||
|
||||
if (r->args.len) {
|
||||
p = (u_char *) ngx_strnstr(r->args.data, "start=", r->args.len);
|
||||
|
||||
if (p) {
|
||||
p += 6;
|
||||
if (ngx_http_arg(r, (u_char *) "start", 5, &value) == NGX_OK) {
|
||||
|
||||
for (n = p; n < r->args.data + r->args.len; n++) {
|
||||
if (*n == '&') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
start = ngx_atoof(p, n - p);
|
||||
start = ngx_atoof(value.data, value.len);
|
||||
|
||||
if (start == NGX_ERROR || start >= len) {
|
||||
start = 0;
|
||||
|
@ -76,6 +76,9 @@ ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b,
|
||||
ngx_uint_t allow_underscores);
|
||||
ngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers,
|
||||
ngx_str_t *name, ngx_str_t *value);
|
||||
ngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len,
|
||||
ngx_str_t *value);
|
||||
|
||||
|
||||
ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r);
|
||||
void ngx_http_update_location_config(ngx_http_request_t *r);
|
||||
|
@ -1481,3 +1481,45 @@ ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name,
|
||||
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
|
||||
{
|
||||
u_char *p;
|
||||
|
||||
if (r->args.len == 0) {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
for (p = r->args.data; *p && *p != ' '; p++) {
|
||||
|
||||
/*
|
||||
* although r->args.data is not null-terminated by itself,
|
||||
* however, there is null in the end of request line
|
||||
*/
|
||||
|
||||
p = ngx_strcasestrn(p, (char *) name, len - 1);
|
||||
|
||||
if (p == NULL) {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') {
|
||||
|
||||
value->data = p + len + 1;
|
||||
|
||||
p = (u_char *) ngx_strchr(p, '&');
|
||||
|
||||
if (p == NULL) {
|
||||
p = r->args.data + r->args.len;
|
||||
}
|
||||
|
||||
value->len = p - value->data;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
@ -772,51 +772,23 @@ ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
{
|
||||
ngx_str_t *name = (ngx_str_t *) data;
|
||||
|
||||
u_char *p, *arg;
|
||||
size_t len;
|
||||
u_char *arg;
|
||||
size_t len;
|
||||
ngx_str_t value;
|
||||
|
||||
if (r->args.len == 0) {
|
||||
len = name->len - (sizeof("arg_") - 1);
|
||||
arg = name->data + sizeof("arg_") - 1;
|
||||
|
||||
if (ngx_http_arg(r, arg, len, &value) != NGX_OK) {
|
||||
v->not_found = 1;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
len = name->len - 1 - (sizeof("arg_") - 1);
|
||||
arg = name->data + sizeof("arg_") - 1;
|
||||
|
||||
for (p = r->args.data; *p && *p != ' '; p++) {
|
||||
|
||||
/*
|
||||
* although r->args.data is not null-terminated by itself,
|
||||
* however, there is null in the end of request line
|
||||
*/
|
||||
|
||||
p = ngx_strcasestrn(p, (char *) arg, len);
|
||||
|
||||
if (p == NULL) {
|
||||
v->not_found = 1;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
if ((p == r->args.data || *(p - 1) == '&') && *(p + len + 1) == '=') {
|
||||
|
||||
v->data = p + len + 2;
|
||||
|
||||
p = (u_char *) ngx_strchr(p, '&');
|
||||
|
||||
if (p == NULL) {
|
||||
p = r->args.data + r->args.len;
|
||||
}
|
||||
|
||||
v->len = p - v->data;
|
||||
v->valid = 1;
|
||||
v->no_cacheable = 0;
|
||||
v->not_found = 0;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
v->not_found = 1;
|
||||
v->data = value.data;
|
||||
v->len = value.len;
|
||||
v->valid = 1;
|
||||
v->no_cacheable = 0;
|
||||
v->not_found = 0;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user