Skip to content

Commit d3a43ba

Browse files
committed
HTTP method does not passed well if tnt_eval used. As fix: If request has parent request, then it will use parent's request method
1 parent 26a4956 commit d3a43ba

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

src/ngx_http_tnt_handlers.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ ngx_http_tnt_get_request_data(ngx_http_request_t *r,
430430
{
431431
char *root_map_place;
432432
char *map_place;
433+
const char *method_name;
434+
size_t method_len;
433435
size_t root_items;
434436
size_t map_items;
435437
ngx_buf_t *b;
@@ -456,10 +458,17 @@ ngx_http_tnt_get_request_data(ngx_http_request_t *r,
456458
*/
457459
++root_items;
458460

461+
if (r->parent) {
462+
method_name = (const char *) r->parent->method_name.data;
463+
method_len = r->parent->method_name.len;
464+
} else {
465+
method_name = (const char*) r->method_name.data;
466+
method_len = r->method_name.len;
467+
}
468+
459469
if (!tp_encode_str_map_item(tp,
460470
"method", sizeof("method")-1,
461-
(const char*)r->method_name.data,
462-
r->method_name.len))
471+
method_name, method_len))
463472
{
464473
return NGX_ERROR;
465474
}

src/ngx_http_tnt_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
#ifndef NGX_HTTP_TNT_VERSION_H
3434
#define NGX_HTTP_TNT_VERSION_H 1
3535

36-
#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.4.2-beta"
36+
#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.4.3-beta"
3737

3838
#endif

test/eval_basic.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
http_codes = [
1717
'200',
18-
'201',
19-
'202',
18+
2019
## TODO Fix [[[
20+
# '201',
21+
# '202',
2122
#'204',
2223
#'206',
2324
#'300',
@@ -54,7 +55,9 @@
5455

5556
methods = [
5657
[post_2, 'POST'],
58+
# Fix this [[
5759
# [get_2, 'GET']
60+
# ]]
5861
]
5962

6063
prev_result = None
@@ -67,16 +70,19 @@
6770
if VERBOSE:
6871
print (curl)
6972

73+
if method[1] == 'GET' and (code == '404' or code == '405'):
74+
continue
75+
7076
(rcode, result) = method[0](curl, [], [])
7177
assert(rcode == int(code)), 'expected ' + code
7278

7379
if prev_result:
7480

7581
if VERBOSE:
7682
print ('===============')
77-
print (curl, method[1])
78-
print (prev_result[1])
79-
print (result)
83+
print ('req = ', curl, method[1])
84+
print ('prev = ', prev_result[1])
85+
print ('curr = ', result)
8086

8187
# Here is we don't test those fields [[[
8288
prev_result[1]['args']['status_code'] = code

test/ngx_confs/tnt_server_test.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ http {
66
include mime.types;
77
default_type application/octet-stream;
88

9-
client_body_buffer_size 10m;
9+
client_body_buffer_size 1m;
1010
client_header_buffer_size 1k;
1111
client_max_body_size 64m;
1212
large_client_header_buffers 2 1k;
@@ -32,7 +32,6 @@ http {
3232
}
3333

3434
location = /tnt {
35-
client_body_buffer_size 200m;
3635
tnt_pass tnt;
3736
}
3837
location /echo_2 {

test/test.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ function test_eval(req)
146146
for i = 0, 1801 do
147147
out[i] = i;
148148
end
149-
150149
return
151150
{
152151
__ngx = {

test/v20_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
preset_method_location = BASE_URL + '/rest_api_parse_query_args'
9595

9696
obj = {}
97-
for i in range(1, 10000):
97+
for i in range(1, 30000):
9898
obj[str(i) + 'some_key_name'] = [ i, { 'n': i,
9999
'some_key_name': [[1,2,3],[4]]}]
100100
for i in range(1, 10):

0 commit comments

Comments
 (0)