/*
* TODO:
* - write documentation
+ * - CGI/1.1 conformance
+ * - HTTP basic auth
*/
/* $Id$ */
* with a number of variables. HTTP_* variables are created for
* the HTTP header data, so that a script can access these.
*/
+#define ADD_STRING(name) \
+ MAKE_STD_ZVAL(pval); \
+ pval->type = IS_STRING; \
+ pval->value.str.len = strlen(buf); \
+ pval->value.str.val = estrndup(buf, pval->value.str.len); \
+ zend_hash_update(&EG(symbol_table), name, sizeof(name), \
+ &pval, sizeof(zval *), NULL)
static void
php_ns_hash_environment(NSLS_D CLS_DC ELS_DC PLS_DC SLS_DC)
}
snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
+ ADD_STRING("SERVER_SOFTWARE");
+ snprintf(buf, 511, "HTTP/%1.1f", NSG(conn)->request->version);
+ ADD_STRING("SERVER_PROTOCOL");
+
+ strncpy(buf, NSG(conn)->request->method, 511);
+ ADD_STRING("REQUEST_METHOD");
+
+ if(NSG(conn)->request->query) {
+ strncpy(buf, NSG(conn)->request->query, 511);
+ } else {
+ buf[0] = '\0';
+ }
+ ADD_STRING("QUERY_STRING");
- MAKE_STD_ZVAL(pval);
- pval->type = IS_STRING;
- pval->value.str.len = strlen(buf);
- pval->value.str.val = estrndup(buf, pval->value.str.len);
- zend_hash_update(&EG(symbol_table), "SERVER_SOFTWARE", sizeof("SERVER_SOFTWARE"), &pval, sizeof(zval *), NULL);
+ strncpy(buf, Ns_InfoBuildDate(), 511);
+ ADD_STRING("SERVER_BUILDDATE");
+
+ strncpy(buf, Ns_ConnPeer(NSG(conn)), 511);
+ ADD_STRING("REMOTE_ADDR");
MAKE_STD_ZVAL(pval);
pval->type = IS_LONG;
pval->value.lval = Ns_InfoBootTime();
zend_hash_update(&EG(symbol_table), "SERVER_BOOTTIME", sizeof("SERVER_BOOTTIME"), &pval, sizeof(zval *), NULL);
-
- MAKE_STD_ZVAL(pval);
- pval->type = IS_STRING;
- pval->value.str.val = estrdup(Ns_InfoBuildDate());
- pval->value.str.len = strlen(pval->value.str.val);
- zend_hash_update(&EG(symbol_table), "SERVER_BUILDDATE", sizeof("SERVER_BUILDDATE"), &pval, sizeof(zval *), NULL);
-
- snprintf(buf, 511, "HTTP/%1.1f", NSG(conn)->request->version);
- MAKE_STD_ZVAL(pval);
- pval->type = IS_STRING;
- pval->value.str.len = strlen(buf);
- pval->value.str.val = estrndup(buf, pval->value.str.len);
- zend_hash_update(&EG(symbol_table), "SERVER_PROTOCOL", sizeof("SERVER_PROTOCOL"), &pval, sizeof(zval *), NULL);
}
/*