Skip to content

Commit 5fa4789

Browse files
authored
test: fix broken chunked test (#12)
1 parent 029f427 commit 5fa4789

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

src/ngx_http_apisix_module.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ngx_http_apisix_client_set_max_body_size(ngx_http_request_t *r,
301301

302302
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
303303
"set client max body size %O",
304-
ctx->client_max_body_size);
304+
bytes);
305305

306306
ctx->client_max_body_size = bytes;
307307
ctx->client_max_body_size_set = 1;

t/client.t

+34-14
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,23 @@ client intended to send too large body
9191
client_max_body_size 1;
9292
access_by_lua_block {
9393
local client = require("resty.apisix.client")
94-
assert(client.set_client_max_body_size(126))
94+
assert(client.set_client_max_body_size(5))
9595
}
9696
content_by_lua_block {
9797
ngx.req.read_body()
9898
ngx.exit(200)
9999
}
100100
}
101-
--- request eval
102-
qq{POST /t\n-----------------------------820127721219505131303151179\r
101+
--- raw_request eval
102+
qq{POST /t HTTP/1.1\r
103+
Host: localhost\r
104+
Transfer-Encoding: chunked\r
105+
Connection: close\r
106+
\r
107+
5\r
108+
Hello\r
109+
0\r
103110
\r
104-
Hello\r\n-----------------------------820127721219505131303151179--\r
105111
}
106112
107113
@@ -112,21 +118,27 @@ Hello\r\n-----------------------------820127721219505131303151179--\r
112118
client_max_body_size 1;
113119
access_by_lua_block {
114120
local client = require("resty.apisix.client")
115-
assert(client.set_client_max_body_size(2))
121+
assert(client.set_client_max_body_size(4))
116122
}
117123
content_by_lua_block {
118124
ngx.req.read_body()
119125
ngx.exit(200)
120126
}
121127
}
122-
--- request eval
123-
qq{POST /t\n-----------------------------820127721219505131303151179\r
128+
--- raw_request eval
129+
qq{POST /t HTTP/1.1\r
130+
Host: localhost\r
131+
Transfer-Encoding: chunked\r
132+
Connection: close\r
133+
\r
134+
5\r
135+
Hello\r
136+
0\r
124137
\r
125-
Hello\r\n-----------------------------820127721219505131303151179--\r
126138
}
127139
--- error_code: 413
128140
--- error_log
129-
client intended to send too large body
141+
client intended to send too large chunked body
130142
131143
132144
@@ -143,10 +155,14 @@ client intended to send too large body
143155
ngx.exit(200)
144156
}
145157
}
158+
--- more_headers
159+
Transfer-Encoding: chunked
146160
--- request eval
147-
qq{POST /t\n-----------------------------820127721219505131303151179\r
161+
qq{POST /t
162+
5\r
163+
Hello\r
164+
0\r
148165
\r
149-
Hello\r\n-----------------------------820127721219505131303151179--\r
150166
}
151167
--- use_http2
152168
@@ -165,15 +181,19 @@ Hello\r\n-----------------------------820127721219505131303151179--\r
165181
ngx.exit(200)
166182
}
167183
}
184+
--- more_headers
185+
Transfer-Encoding: chunked
168186
--- request eval
169-
qq{POST /t\n-----------------------------820127721219505131303151179\r
187+
qq{POST /t
188+
11\r
189+
Hello World\r
190+
0\r
170191
\r
171-
Hello\r\n-----------------------------820127721219505131303151179--\r
172192
}
173193
--- use_http2
174194
--- error_code: 413
175195
--- error_log
176-
client intended to send too large body
196+
client intended to send too large chunked body
177197
178198
179199

0 commit comments

Comments
 (0)