Skip to content

Commit

Permalink
HH-63864 rename requestid
Browse files Browse the repository at this point in the history
  • Loading branch information
phiksonic committed Nov 1, 2016
1 parent de3d1dc commit 7b09e6d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions README
@@ -1,8 +1,8 @@
The ngx_http_requestid_module is designed to generate a unique request identificator.

The module sets $request_id variable with a unique request ID.
The module sets $trequest_id variable with a unique request ID.

The $request_id variable is composed of (time){13} and (md5(ngx_pid, connection_number, rand())){19}, where:
The $trequest_id variable is composed of (time){13} and (md5(ngx_pid, connection_number, rand())){19}, where:
* time - timestamp in milliseconds
  * ngx_pid - nginx process id
  * connection_number - connection counter value local to worker process
Expand All @@ -14,26 +14,26 @@ Example configurations:

# Set Proxy Header
location / {
     requestid on;
     trequestid on;
     proxy_pass http://127.0.0.1;
     proxy_set_header X-Request-Id $request_id;
     proxy_set_header X-Request-Id $trequest_id;
}


# Set HTTP Header
location / {
add_header X-Request-Id $request_id;
add_header X-Request-Id $trequest_id;
}

# Write request id to log
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent $request_id '
'"$request" $status $body_bytes_sent $trequest_id '
'"$http_referer" "$http_user_agent"';


Configuration:

syntax: requestid on | off
syntax: trequestid on | off
default: off
context: server, location

4 changes: 2 additions & 2 deletions src/ngx_http_requestid_module.c
Expand Up @@ -12,7 +12,7 @@ typedef struct {
} ngx_http_requestid_conf_t;


static ngx_str_t ngx_http_requestid = ngx_string("request_id");
static ngx_str_t ngx_http_requestid = ngx_string("trequest_id");
static const u_char hex[] = "0123456789abcdef";

static ngx_int_t ngx_http_requestid_add_variables(ngx_conf_t *cf);
Expand All @@ -23,7 +23,7 @@ static char *ngx_http_requestid_merge_conf(ngx_conf_t *cf, void *parent,

static ngx_command_t ngx_http_requestid_commands[] = {
{
ngx_string("requestid"),
ngx_string("trequestid"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
Expand Down
28 changes: 14 additions & 14 deletions t/test.t
Expand Up @@ -7,8 +7,8 @@ __DATA__
=== TEST 1: Check request id pattern
--- config
location = /test {
requestid on;
return 200 "$request_id";
trequestid on;
return 200 "$trequest_id";
}
--- request
GET /test
Expand All @@ -17,11 +17,11 @@ GET /test
=== TEST 2: Check server and location both on
--- config
requestid on;
trequestid on;
location = /test {
requestid on;
return 200 "$request_id";
trequestid on;
return 200 "$trequest_id";
}
--- request
GET /test
Expand All @@ -30,10 +30,10 @@ GET /test
=== TEST 3: Check server directive only
--- config
requestid on;
trequestid on;
location = /test {
return 200 "$request_id";
return 200 "$trequest_id";
}
--- request
GET /test
Expand All @@ -42,11 +42,11 @@ GET /test
=== TEST 4: Check disabled for location
--- config
requestid on;
trequestid on;
location = /test {
requestid off;
return 200 "$request_id";
trequestid off;
return 200 "$trequest_id";
}
--- request
GET /test
Expand All @@ -55,13 +55,13 @@ GET /test
=== TEST 5: Check location with if
--- config
requestid on;
trequestid on;
location = /test {
if ( $request_method = POST ) {
return 406;
}
return 200 "$request_id";
return 200 "$trequest_id";
}
--- request
GET /test
Expand All @@ -70,15 +70,15 @@ GET /test
=== TEST 6: Test http context forbidden
--- http_config
requestid on;
trequestid on;
--- config
--- must_die
=== TEST 7: No request id by default
--- config
location = /test {
return 200 "$request_id";
return 200 "$trequest_id";
}
--- request
GET /test
Expand Down

0 comments on commit 7b09e6d

Please sign in to comment.