]> git.kaiwu.me - njs.git/commitdiff
HTTP: renaming reqBody,resBody to requestBuffer and responseBuffer.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 27 Nov 2020 12:28:44 +0000 (12:28 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 27 Nov 2020 12:28:44 +0000 (12:28 +0000)
In 434f20c29f4c, r.reqBody and r.resBody were introduced.  Since quite
often request body and response body are valid strings, it is preferable
to leave both variants to avoid potential conversions.

To make distinction clearer, requestText and responseText aliases to
requestBody and responseBody were also added.

nginx/ngx_http_js_module.c

index a576fab5f72e06100ac912b7ab908dcd5f4889ab..9a6c5cd9c582e092d9342c14fd6ec408b1f151d4 100644 (file)
@@ -328,8 +328,17 @@ static njs_external_t  ngx_http_js_ext_request[] = {
 
     {
         .flags = NJS_EXTERN_PROPERTY,
-        .name.string = njs_str("reqBody"),
+        .name.string = njs_str("requestText"),
         .enumerable = 1,
+        .u.property = {
+            .handler = ngx_http_js_ext_get_request_body,
+            .magic32 = NGX_JS_STRING,
+        }
+    },
+
+    {
+        .flags = NJS_EXTERN_PROPERTY,
+        .name.string = njs_str("requestBuffer"),
         .u.property = {
             .handler = ngx_http_js_ext_get_request_body,
             .magic32 = NGX_JS_BUFFER,
@@ -355,8 +364,17 @@ static njs_external_t  ngx_http_js_ext_request[] = {
 
     {
         .flags = NJS_EXTERN_PROPERTY,
-        .name.string = njs_str("resBody"),
+        .name.string = njs_str("responseText"),
         .enumerable = 1,
+        .u.property = {
+            .handler = ngx_http_js_ext_get_response_body,
+            .magic32 = NGX_JS_STRING,
+        }
+    },
+
+    {
+        .flags = NJS_EXTERN_PROPERTY,
+        .name.string = njs_str("responseBuffer"),
         .u.property = {
             .handler = ngx_http_js_ext_get_response_body,
             .magic32 = NGX_JS_BUFFER,