1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

change r.content_type = "something" to use ap_set_content_type, which it should as was pointed out by Bertrand Mansion

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@748946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brian McCallister
2009-03-01 01:25:27 +00:00
parent e171af3118
commit d68a529544
3 changed files with 5 additions and 20 deletions

View File

@@ -450,46 +450,29 @@ static int req_newindex(lua_State *L)
/* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */ /* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */
/* const char* key = luaL_checkstring(L, -2); */ /* const char* key = luaL_checkstring(L, -2); */
request_rec *r = apl_check_request_rec(L, 1); request_rec *r = apl_check_request_rec(L, 1);
apl_rstack_dump(L, r, "req_newindex");
key = luaL_checkstring(L, 2); key = luaL_checkstring(L, 2);
apl_rstack_dump(L, r, "req_newindex"); apl_rstack_dump(L, r, "req_newindex");
if (0 == apr_strnatcmp("status", key)) { if (0 == apr_strnatcmp("status", key)) {
int code = luaL_checkinteger(L, 3); int code = luaL_checkinteger(L, 3);
r->status = code; r->status = code;
luaL_getmetatable(L, "Apache2.Request");
lua_pushinteger(L, code);
lua_setfield(L, -2, "status");
lua_pop(L, 1);
return 0; return 0;
} }
if (0 == apr_strnatcmp("content_type", key)) { if (0 == apr_strnatcmp("content_type", key)) {
const char *value = luaL_checkstring(L, 3); const char *value = luaL_checkstring(L, 3);
r->content_type = apr_pstrdup(r->pool, value); ap_set_content_type(r, apr_pstrdup(r->pool, value));
luaL_getmetatable(L, "Apache2.Request");
lua_pushstring(L, value);
lua_setfield(L, -2, "content_type");
lua_pop(L, 1);
return 0; return 0;
} }
if (0 == apr_strnatcmp("filename", key)) { if (0 == apr_strnatcmp("filename", key)) {
const char *value = luaL_checkstring(L, 3); const char *value = luaL_checkstring(L, 3);
r->filename = apr_pstrdup(r->pool, value); r->filename = apr_pstrdup(r->pool, value);
luaL_getmetatable(L, "Apache2.Request");
lua_pushstring(L, value);
lua_setfield(L, -2, "filename");
lua_pop(L, 1);
return 0; return 0;
} }
if (0 == apr_strnatcmp("uri", key)) { if (0 == apr_strnatcmp("uri", key)) {
const char *value = luaL_checkstring(L, 3); const char *value = luaL_checkstring(L, 3);
r->uri = apr_pstrdup(r->pool, value); r->uri = apr_pstrdup(r->pool, value);
luaL_getmetatable(L, "Apache2.Request");
lua_pushstring(L, value);
lua_setfield(L, -2, "uri");
lua_pop(L, 1);
return 0; return 0;
} }

View File

@@ -236,7 +236,8 @@ static void munge_path(lua_State *L,
const char *sub_pat, const char *sub_pat,
const char *rep_pat, const char *rep_pat,
apr_pool_t *pool, apr_pool_t *pool,
apr_array_header_t *paths, const char *file) apr_array_header_t *paths,
const char *file)
{ {
const char *current; const char *current;
const char *parent_dir; const char *parent_dir;

View File

@@ -1,3 +1,4 @@
function handle(r) function handle(r)
r:puts("Hi!") r.content_type = "text/plain"
r:puts("Hi there!")
end end