summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs/unit-http/unit.cpp
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2019-04-01 16:40:49 +0300
committerMax Romanov <max.romanov@nginx.com>2019-04-01 16:40:49 +0300
commit56101e47eebbb818718772c85a8ff3e689ef7bcd (patch)
tree5dd263ef69c3a15abbf53cbad0b746170d7e3c83 /src/nodejs/unit-http/unit.cpp
parent8557cb366092ea1bbc88386bdd79b9dad5867f19 (diff)
downloadunit-56101e47eebbb818718772c85a8ff3e689ef7bcd.tar.gz
unit-56101e47eebbb818718772c85a8ff3e689ef7bcd.tar.bz2
Adding 'connection' to request as an alias to 'socket'.
Adding actual 'remoteAddress' and 'localAddress' into socket object. This closes #232 issue on GitHub.
Diffstat (limited to '')
-rw-r--r--src/nodejs/unit-http/unit.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nodejs/unit-http/unit.cpp b/src/nodejs/unit-http/unit.cpp
index e0cfaba3..6da890ce 100644
--- a/src/nodejs/unit-http/unit.cpp
+++ b/src/nodejs/unit-http/unit.cpp
@@ -399,15 +399,20 @@ Unit::append_header(nxt_unit_field_t *f, napi_value headers,
napi_value
Unit::create_socket(napi_value server_obj, nxt_unit_request_info_t *req)
{
- napi_value constructor, return_val;
+ napi_value constructor, res;
+ nxt_unit_request_t *r;
+
+ r = req->request;
constructor = get_named_property(server_obj, "socket");
- return_val = new_instance(constructor);
+ res = new_instance(constructor);
- set_named_property(return_val, "req_pointer", (intptr_t) req);
+ set_named_property(res, "req_pointer", (intptr_t) req);
+ set_named_property(res, "remoteAddress", r->remote, r->remote_length);
+ set_named_property(res, "localAddress", r->local, r->local_length);
- return return_val;
+ return res;
}
@@ -421,6 +426,7 @@ Unit::create_request(napi_value server_obj, napi_value socket)
return_val = new_instance(constructor, server_obj);
set_named_property(return_val, "socket", socket);
+ set_named_property(return_val, "connection", socket);
return return_val;
}
@@ -437,6 +443,7 @@ Unit::create_response(napi_value server_obj, napi_value socket,
return_val = new_instance(constructor, request);
set_named_property(return_val, "socket", socket);
+ set_named_property(return_val, "connection", socket);
set_named_property(return_val, "_req_point", (intptr_t) req);
return return_val;