Skip to content
Browse files

more JSGI request vars

  • Loading branch information...
1 parent 0aa5201 commit 1b5e98f59393328613be49e154b9b351b88693a3 @unbit committed Apr 2, 2013
Showing with 26 additions and 0 deletions.
  1. +5 −0 plugins/v8/plugin.c
  2. +21 −0 plugins/v8/v8_jsgi.cc
View
5 plugins/v8/plugin.c
@@ -17,6 +17,10 @@ extern struct uwsgi_option uwsgi_v8_options[];
int uwsgi_v8_request(struct wsgi_request *);
+static void uwsgi_v8_after_request(struct wsgi_request *wsgi_req) {
+ log_request(wsgi_req);
+}
+
struct uwsgi_plugin v8_plugin = {
.name = "v8",
.modifier1 = 24,
@@ -26,6 +30,7 @@ struct uwsgi_plugin v8_plugin = {
.on_load = uwsgi_v8_register,
.rpc = uwsgi_v8_rpc,
.request = uwsgi_v8_request,
+ .after_request = uwsgi_v8_after_request,
.signal_handler = uwsgi_v8_signal_handler,
.enable_threads = uwsgi_v8_enable_threads,
.init_thread = uwsgi_v8_init_thread,
View
21 plugins/v8/v8_jsgi.cc
@@ -30,6 +30,27 @@ static void uwsgi_v8_jsgi_fill_request(struct wsgi_request *wsgi_req, v8::Handle
else {
o->Set(v8::String::New("scheme"), v8::String::New("http"));
}
+ o->Set(v8::String::New("remoteAddr"), v8::String::New(wsgi_req->remote_addr, wsgi_req->remote_addr_len));
+ if (wsgi_req->remote_user_len) {
+ o->Set(v8::String::New("remoteUser"), v8::String::New(wsgi_req->remote_user, wsgi_req->remote_user_len));
+ }
+ o->Set(v8::String::New("serverSoftware"), v8::String::New("uWSGI " UWSGI_VERSION));
+
+ v8::Handle<v8::Value> jsgi = v8::Object::New();
+ if (uwsgi.threads > 1) {
+ jsgi->ToObject()->Set(v8::String::New("multithread"), v8::True());
+ }
+ else {
+ jsgi->ToObject()->Set(v8::String::New("multithread"), v8::False());
+ }
+
+ if (uwsgi.numproc > 1) {
+ jsgi->ToObject()->Set(v8::String::New("multiprocess"), v8::True());
+ }
+ else {
+ jsgi->ToObject()->Set(v8::String::New("multiprocess"), v8::False());
+ }
+ o->Set(v8::String::New("jsgi"), jsgi);
}
extern "C" int uwsgi_v8_request(struct wsgi_request *wsgi_req) {

0 comments on commit 1b5e98f

Please sign in to comment.
Something went wrong with that request. Please try again.