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

mod_lua: If the first yield() of a LuaOutputFilter returns a string, it should

be prefixed to the response as documented.

Also, don't put empty heap buckets in the brigade if a yield() is called with 
no string.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1519492 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eric Covener
2013-09-02 18:38:07 +00:00
parent 918ccd0014
commit 227ffd6486
2 changed files with 36 additions and 12 deletions

View File

@@ -1,6 +1,9 @@
-*- coding: utf-8 -*- -*- coding: utf-8 -*-
Changes with Apache 2.5.0 Changes with Apache 2.5.0
*) mod_lua: If the first yield() of a LuaOutputFilter returns a string, it should
be prefixed to the response as documented. [Eric Covener]
*) mod_lua: Remove ETAG, Content-Length, and Content-MD5 when a LuaOutputFilter *) mod_lua: Remove ETAG, Content-Length, and Content-MD5 when a LuaOutputFilter
is configured without mod_filter. [Eric Covener] is configured without mod_filter. [Eric Covener]

View File

@@ -416,8 +416,25 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
ap_remove_output_filter(f); ap_remove_output_filter(f);
return ap_pass_brigade(f->next,pbbIn); return ap_pass_brigade(f->next,pbbIn);
} }
f->ctx = ctx; else {
ctx->tmpBucket = apr_brigade_create(r->pool, c->bucket_alloc); /* We've got a willing lua filter, setup and check for a prefix */
size_t olen;
apr_bucket *pbktOut;
const char* output = lua_tolstring(ctx->L, 1, &olen);
f->ctx = ctx;
ctx->tmpBucket = apr_brigade_create(r->pool, c->bucket_alloc);
if (olen > 0) {
pbktOut = apr_bucket_heap_create(output, olen, NULL, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut);
rv = ap_pass_brigade(f->next, ctx->tmpBucket);
apr_brigade_cleanup(ctx->tmpBucket);
if (rv != APR_SUCCESS) {
return rv;
}
}
}
} }
ctx = (lua_filter_ctx*) f->ctx; ctx = (lua_filter_ctx*) f->ctx;
L = ctx->L; L = ctx->L;
@@ -442,13 +459,15 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
if (lua_resume(L, 0) == LUA_YIELD) { if (lua_resume(L, 0) == LUA_YIELD) {
size_t olen; size_t olen;
const char* output = lua_tolstring(L, 1, &olen); const char* output = lua_tolstring(L, 1, &olen);
pbktOut = apr_bucket_heap_create(output, olen, NULL, if (olen > 0) {
c->bucket_alloc); pbktOut = apr_bucket_heap_create(output, olen, NULL,
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut); c->bucket_alloc);
rv = ap_pass_brigade(f->next, ctx->tmpBucket); APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut);
apr_brigade_cleanup(ctx->tmpBucket); rv = ap_pass_brigade(f->next, ctx->tmpBucket);
if (rv != APR_SUCCESS) { apr_brigade_cleanup(ctx->tmpBucket);
return rv; if (rv != APR_SUCCESS) {
return rv;
}
} }
} }
else { else {
@@ -470,9 +489,11 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
apr_bucket *pbktOut; apr_bucket *pbktOut;
size_t olen; size_t olen;
const char* output = lua_tolstring(L, 1, &olen); const char* output = lua_tolstring(L, 1, &olen);
pbktOut = apr_bucket_heap_create(output, olen, NULL, if (olen > 0) {
c->bucket_alloc); pbktOut = apr_bucket_heap_create(output, olen, NULL,
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut); c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut);
}
} }
pbktEOS = apr_bucket_eos_create(c->bucket_alloc); pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktEOS); APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktEOS);