[njs] Tests: added request body test when body is in a file.
noreply at nginx.com
noreply at nginx.com
Thu Jan 23 00:06:02 UTC 2025
details: https://github.com/nginx/njs/commit/1aabab0c26e83727fa23b66aff1f239c905017f3
branches: master
commit: 1aabab0c26e83727fa23b66aff1f239c905017f3
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri, 17 Jan 2025 17:03:08 -0800
description:
Tests: added request body test when body is in a file.
---
nginx/t/js_request_body.t | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/nginx/t/js_request_body.t b/nginx/t/js_request_body.t
index 350e7fb8..7a5005d4 100644
--- a/nginx/t/js_request_body.t
+++ b/nginx/t/js_request_body.t
@@ -51,12 +51,19 @@ http {
client_body_in_file_only on;
js_content test.body;
}
+
+ location /read_body_from_temp_file {
+ client_body_in_file_only clean;
+ js_content test.read_body_from_temp_file;
+ }
}
}
EOF
$t->write_file('test.js', <<EOF);
+ import fs from 'fs';
+
function body(r) {
try {
var body = r.requestText;
@@ -67,11 +74,16 @@ $t->write_file('test.js', <<EOF);
}
}
- export default {body};
+ function read_body_from_temp_file(r) {
+ let fn = r.variables.request_body_file;
+ r.return(200, fs.readFileSync(fn));
+ }
+
+ export default {body, read_body_from_temp_file};
EOF
-$t->try_run('no njs request body')->plan(3);
+$t->try_run('no njs request body')->plan(4);
###############################################################################
@@ -80,6 +92,8 @@ like(http_post('/in_file'), qr/request body is in a file/,
'request body in file');
like(http_post_big('/body'), qr/200.*^(1234567890){1024}$/ms,
'request body big');
+like(http_post_big('/read_body_from_temp_file'),
+ qr/200.*^(1234567890){1024}$/ms, 'request body big from temp file');
###############################################################################
More information about the nginx-devel
mailing list