]> granicus.if.org Git - apache/commitdiff
Add in the ability to fetch from headers_in.
authorPaul Querna <pquerna@apache.org>
Wed, 24 Dec 2008 02:22:38 +0000 (02:22 +0000)
committerPaul Querna <pquerna@apache.org>
Wed, 24 Dec 2008 02:22:38 +0000 (02:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@729194 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_request.c

index 4c5fcd83c9a6f2aa763de286b4fe77a975b9ad7f..8c606a7f665030737bd7113cbada11a5dd1abe32 100644 (file)
@@ -428,6 +428,25 @@ static int req_debug(lua_State *L)
     return 0;
 }
 
+static int req_headers_in(lua_State *L)
+{
+    const char *key;
+    const char *value;
+    request_rec *r = apl_check_request_rec(L, 1);
+
+    key = luaL_checkstring(L, 2);
+
+    value = apr_table_get(r->headers_in, key);
+    if (value) {
+        lua_pushstring(L, value);
+    }
+    else {
+        lua_pushnil(L);
+    }
+
+    return 1;
+}
+
 /* handle r.status = 201 */
 static int req_newindex(lua_State *L)
 {
@@ -534,7 +553,7 @@ void apl_load_request_lmodule(lua_State *L, apr_pool_t *p)
     apr_hash_set(dispatch, "notice", APR_HASH_KEY_STRING,
                  makefun(&req_notice, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "warn", APR_HASH_KEY_STRING,
-                 makefun(req_warn, APL_REQ_FUNTYPE_LUACFUN, p));
+                 makefun(&req_warn, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "err", APR_HASH_KEY_STRING,
                  makefun(&req_err, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "crit", APR_HASH_KEY_STRING,
@@ -583,6 +602,9 @@ void apl_load_request_lmodule(lua_State *L, apr_pool_t *p)
     apr_hash_set(dispatch, "method", APR_HASH_KEY_STRING,
                  makefun(&req_method_field, APL_REQ_FUNTYPE_STRING, p));
 
+    apr_hash_set(dispatch, "headers_in", APR_HASH_KEY_STRING,
+                 makefun(&req_headers_in, APL_REQ_FUNTYPE_LUACFUN, p));
+
     lua_pushlightuserdata(L, dispatch);
     lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch");