Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Pacheco <dap@joyent.com>2011-06-04 18:04:38 +0400
committerRyan Dahl <ry@tinyclouds.org>2011-06-04 18:05:01 +0400
commite142fe2be6ef3e5cd27b89d59175a3937b9fdb31 (patch)
tree067bdfdcd56a15e274c3fbefa43da1b413a67733 /src/node_dtrace.cc
parentb6a742d76fa8a598f24c8c2ec5b18d0cdc22ef4a (diff)
DTrace probes: support X-Forwarded-For
INTRO-385
Diffstat (limited to 'src/node_dtrace.cc')
-rw-r--r--src/node_dtrace.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc
index 6481267344b..ac14bda104c 100644
--- a/src/node_dtrace.cc
+++ b/src/node_dtrace.cc
@@ -20,6 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <node_dtrace.h>
+#include <strings.h>
#ifdef HAVE_DTRACE
#include "node_provider.h"
@@ -180,7 +181,7 @@ Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
}
Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
- node_dtrace_http_request_t req;
+ node_dtrace_http_server_request_t req;
if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
return Undefined();
@@ -188,10 +189,25 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
HandleScope scope;
Local<Object> arg0 = Local<Object>::Cast(args[0]);
+ Local<Object> headers;
+ bzero(&req, sizeof(req));
+ req._un.version = 1;
SLURP_STRING(arg0, url, &req.url);
SLURP_STRING(arg0, method, &req.method);
+ SLURP_OBJECT(arg0, headers, &headers);
+
+ if (!(headers)->IsObject())
+ return (ThrowException(Exception::Error(String::New("expected "
+ "object for request to contain string member headers"))));
+
+ Local<Value> strfwdfor = headers->Get(String::New("x-forwarded-for"));
+ String::Utf8Value fwdfor(strfwdfor->ToString());
+
+ if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == NULL)
+ req.forwardedFor = "";
+
SLURP_CONNECTION(args[1], conn);
NODE_HTTP_SERVER_REQUEST(&req, &conn);
@@ -211,7 +227,7 @@ Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
}
Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
- node_dtrace_http_request_t req;
+ node_dtrace_http_client_request_t req;
char *header;
if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())