<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -116,6 +116,23 @@ static int exec_javascript(const char *script)
 	return FASTJS_SUCCESS;
 }
 
+static void parse_environment(Handle&lt;ObjectTemplate&gt; _node, char **env)
+{
+	for (; *env != NULL; env++) {
+		gchar **splitted = g_strsplit((const gchar *)(*env), &quot;=&quot;, 2);
+
+		if (splitted == NULL)
+			continue;
+		if ( (splitted[0] == NULL) || (splitted[1] == NULL) ) {
+			g_strfreev(splitted);
+			continue;
+		}
+
+		_node-&gt;Set(String::New((const char *)(splitted[0])), String::New((const char *)(splitted[1])));
+		g_strfreev(splitted);
+	}
+}
+
 static void req_handle(FCGX_Stream *out, char **environment) 
 {
 	if (_jQuery == NULL) {
@@ -127,9 +144,17 @@ static void req_handle(FCGX_Stream *out, char **environment)
 	HandleScope scope;
 	Handle&lt;ObjectTemplate&gt; _global = ObjectTemplate::New();
 	Handle&lt;ObjectTemplate&gt; _fastjs = ObjectTemplate::New();
+	Handle&lt;ObjectTemplate&gt; _env = ObjectTemplate::New();
+	Handle&lt;ObjectTemplate&gt; _fcgi_env = ObjectTemplate::New();
+
+	parse_environment(_env, environment);
+	parse_environment(_fcgi_env, environ);
+
 	_fastjs-&gt;Set(String::New(&quot;write&quot;), FunctionTemplate::New(FastJS_Write));
 	_fastjs-&gt;Set(String::New(&quot;source&quot;), FunctionTemplate::New(FastJS_Source));
 	_fastjs-&gt;Set(String::New(&quot;log&quot;), FunctionTemplate::New(FastJS_Log));
+	_fastjs-&gt;Set(String::New(&quot;env&quot;), _env);
+	_fastjs-&gt;Set(String::New(&quot;fcgi_env&quot;), _fcgi_env);
 
 	_global-&gt;Set(String::New(&quot;fastjs&quot;), _fastjs);
 	Persistent&lt;Context&gt; ctx = Context::New(NULL, _global);
@@ -183,9 +208,6 @@ int main ()
 	
 		req_handle(out, envp);
 
-		//PrintEnv(err, &quot;Request environment&quot;, envp);
-		//PrintEnv(err, &quot;Initial&quot;, environ);
-
 		_error_stream = NULL;
 		_in_stream = NULL;
 		_out_stream = NULL;</diff>
      <filename>fastjs.cc</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@
 #define _FASTJS_H_
 
 #define JQUERY_FILE &quot;jquery-1.3.2.min.js&quot;
-#define JQUERY_COMPAT &quot;if (typeof(window) == 'undefined'){window=new Object();document=window;self=window;navigator=new Object();navigator.userAgent=navigator.userAgent||'FastJS Server';location=new Object();location.href='file:///dev/null';location.protocol='file:';location.host = 'FastJS';}&quot;
+#define JQUERY_COMPAT &quot;if (typeof(window)=='undefined'){window=new Object();document=window;self=window;document.documentElement=new Object();navigator=new Object();navigator.userAgent=navigator.userAgent||'FastJS Server';location=new Object();location.href='file:///dev/null';location.protocol='file:';location.host = 'FastJS';}&quot;
 
 #define FASTJS_SUCCESS 0
 #define FASTJS_COMPILE_ERROR -1</diff>
      <filename>fastjs.h</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@ index.dump_attributes = function(title, obj) {
 	for (var k in obj) {
 		fastjs.write(k + &quot; = &quot;);
 
-		if (typeof(obj[k] != &quot;string&quot;))
+		if (typeof(obj[k]) != &quot;string&quot;)
 			fastjs.write(typeof(obj[k]));
 		else
 			fastjs.write(obj[k]);
@@ -30,10 +30,13 @@ index.dump_attributes = function(title, obj) {
 (function() {
 	index.header();
 
+	fastjs.source(&quot;pages/test.fjs&quot;);
+
 	index.dump_attributes(&quot;window&quot;, window);
-	index.dump_attributes(&quot;jQuery&quot;, jQuery);
+	index.dump_attributes('location', location);
+	index.dump_attributes(&quot;fastjs.env&quot;, fastjs.env);
+	index.dump_attributes(&quot;fastjs.fcgi_env&quot;, fastjs.fcgi_env);
 
-	fastjs.source(&quot;pages/test.fjs&quot;);
 
 	index.footer();
 </diff>
      <filename>pages/index.fjs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>133b8d92df773e71536ec1b1b4d5a7028c17ed7d</id>
    </parent>
  </parents>
  <author>
    <name>R. Tyler Ballance</name>
    <email>tyler@monkeypox.org</email>
  </author>
  <url>http://github.com/rtyler/fastjs/commit/8000bd54ba3c4ab864501b86d3125140069c72ca</url>
  <id>8000bd54ba3c4ab864501b86d3125140069c72ca</id>
  <committed-date>2009-03-09T02:05:04-07:00</committed-date>
  <authored-date>2009-03-09T02:05:04-07:00</authored-date>
  <message>Exposing the request and the FastCGI environments through to the JavaScript through the self.fastjs object

Currently they're typical JavaScript objects tied to:
	fastjs.env
	fastjs.fcgi_env

I think I need a template language now..

Signed-off-by: R. Tyler Ballance &lt;tyler@monkeypox.org&gt;</message>
  <tree>ebcee2996171d0431fbe51ae605448ae1d1531be</tree>
  <committer>
    <name>R. Tyler Ballance</name>
    <email>tyler@monkeypox.org</email>
  </committer>
</commit>
