Index: request.c
===================================================================
--- request.c	(revision 533104)
+++ request.c	(working copy)
@@ -266,13 +266,65 @@
     {NULL, NULL}
 };
 
+static apr_table_t* check_apr_table(lua_State* L, int index) {
+    luaL_checkudata(L, index, "Apr.Table");
+    apr_table_t* t = (apr_table_t*)lua_unboxpointer(L, index);
+    return t;    
+}
+
+static int req_table_set(lua_State* L) {
+    apr_table_t *t = check_apr_table(L, 1);
+    const char* key = luaL_checkstring(L, 2);
+    const char* val = luaL_checkstring(L, 3);
+    
+    /*luaL_getmetatable(L, "Apr.Table");*/
+    apr_table_set(t, key, val);
+    /*lua_pop(L, 1);*/
+    return 0;
+}
+
+static int req_table_get(lua_State* L) {
+    apr_table_t *t = check_apr_table(L, 1);
+    const char* key = luaL_checkstring(L, 2);
+    const char *val = apr_table_get(t, key);
+    lua_pushstring(L, val);
+    return 1;
+}
+
+static const luaL_reg req_table_methods[] = {
+    {"set", req_table_set},
+    {"get", req_table_get},
+    {0, 0}
+};
+
+void apw_push_apr_table(lua_State* L, const char *name, apr_table_t *t) {
+    lua_boxpointer(L, t);    
+    luaL_getmetatable(L, "Apr.Table");
+    lua_setmetatable(L, -2);
+    lua_setfield(L, -2, name);
+}
+
+
 void apw_load_request_lmodule(lua_State *L) {
     luaL_newmetatable(L, "Apache2.Request"); // [metatable]
     lua_pushvalue(L, -1); 
 
     lua_setfield(L, -2, "__index"); 
     luaL_register(L, NULL, request_methods); // [metatable]
+
     lua_pop(L, 2);
+    
+    luaL_newmetatable(L, "Apr.Table");
+    luaL_openlib(L, "apr_table", req_table_methods, 0);
+    lua_pushstring(L, "__index");
+    lua_pushstring(L, "get");
+    lua_gettable(L, 2);  
+    lua_settable(L, 1); 
+
+    lua_pushstring(L, "__newindex");
+    lua_pushstring(L, "set");
+    lua_gettable(L, 2);
+    lua_settable(L, 1);
 }
 
 void apw_push_request(lua_State* L, request_rec* r) {
@@ -280,7 +332,7 @@
     luaL_getmetatable(L, "Apache2.Request");
     lua_setmetatable(L, -2);
     luaL_getmetatable(L, "Apache2.Request");
-        
+
     lua_pushinteger(L, r->status);
     lua_setfield(L, -2, "status");
         
@@ -332,6 +384,9 @@
     lua_pushcfunction(L, &req_add_output_filter);
     lua_setfield(L, -2, "addoutputfilter");
 
+    apw_push_apr_table(L, "headers_out", r->headers_out);
+    apw_push_apr_table(L, "headers_in", r->headers_in);
+
     lua_pushlightuserdata(L, r);
     lua_pushcclosure(L, &req_newindex, 1);
     lua_setfield(L, -2, "__newindex");
