You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2013/09/02 20:38:08 UTC
svn commit: r1519492 - in /httpd/httpd/trunk: CHANGES modules/lua/mod_lua.c
Author: covener
Date: Mon Sep 2 18:38:07 2013
New Revision: 1519492
URL: http://svn.apache.org/r1519492
Log:
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.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/lua/mod_lua.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1519492&r1=1519491&r2=1519492&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Sep 2 18:38:07 2013
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
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
is configured without mod_filter. [Eric Covener]
Modified: httpd/httpd/trunk/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=1519492&r1=1519491&r2=1519492&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Mon Sep 2 18:38:07 2013
@@ -416,8 +416,25 @@ static apr_status_t lua_output_filter_ha
ap_remove_output_filter(f);
return ap_pass_brigade(f->next,pbbIn);
}
- f->ctx = ctx;
- ctx->tmpBucket = apr_brigade_create(r->pool, c->bucket_alloc);
+ else {
+ /* 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;
L = ctx->L;
@@ -442,13 +459,15 @@ static apr_status_t lua_output_filter_ha
if (lua_resume(L, 0) == LUA_YIELD) {
size_t olen;
const char* output = lua_tolstring(L, 1, &olen);
- 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;
+ 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;
+ }
}
}
else {
@@ -470,9 +489,11 @@ static apr_status_t lua_output_filter_ha
apr_bucket *pbktOut;
size_t olen;
const char* output = lua_tolstring(L, 1, &olen);
- pbktOut = apr_bucket_heap_create(output, olen, NULL,
- c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut);
+ if (olen > 0) {
+ pbktOut = apr_bucket_heap_create(output, olen, NULL,
+ c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktOut);
+ }
}
pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->tmpBucket, pbktEOS);