You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2011/08/20 20:29:03 UTC
svn commit: r1159896 - in /httpd/httpd/trunk/modules: filters/mod_include.c
http/http_filters.c
Author: sf
Date: Sat Aug 20 18:29:02 2011
New Revision: 1159896
URL: http://svn.apache.org/viewvc?rev=1159896&view=rev
Log:
Simplify some overly complicated code using apr_brigade_putstrs and apr_pstrcat
Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>,
Stefan Fritsch
Modified:
httpd/httpd/trunk/modules/filters/mod_include.c
httpd/httpd/trunk/modules/http/http_filters.c
Modified: httpd/httpd/trunk/modules/filters/mod_include.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_include.c?rev=1159896&r1=1159895&r2=1159896&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_include.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_include.c Sat Aug 20 18:29:02 2011
@@ -2680,36 +2680,18 @@ static apr_status_t handle_printenv(incl
for (i = 0; i < arr->nelts; ++i) {
const char *key_text, *val_text;
- char *key_val, *next;
- apr_size_t k_len, v_len, kv_length;
/* get key */
key_text = ap_escape_html(ctx->dpool, elts[i].key);
- k_len = strlen(key_text);
/* get value */
val_text = elts[i].val;
- if (val_text == LAZY_VALUE) {
+ if (val_text == LAZY_VALUE)
val_text = add_include_vars_lazy(r, elts[i].key, ctx->time_str);
- }
val_text = ap_escape_html(ctx->dpool, val_text);
- v_len = strlen(val_text);
-
- /* assemble result */
- kv_length = k_len + v_len + sizeof("=\n");
- key_val = apr_palloc(ctx->pool, kv_length);
- next = key_val;
-
- memcpy(next, key_text, k_len);
- next += k_len;
- *next++ = '=';
- memcpy(next, val_text, v_len);
- next += v_len;
- *next++ = '\n';
- *next = 0;
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(key_val, kv_length-1,
- ctx->pool, f->c->bucket_alloc));
+ apr_brigade_putstrs(bb, NULL, NULL, key_text, "=", val_text, "\n",
+ NULL);
}
ctx->flush_now = 1;
Modified: httpd/httpd/trunk/modules/http/http_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1159896&r1=1159895&r2=1159896&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/http_filters.c (original)
+++ httpd/httpd/trunk/modules/http/http_filters.c Sat Aug 20 18:29:02 2011
@@ -655,23 +655,10 @@ static int form_header_field(header_stru
#if APR_CHARSET_EBCDIC
char *headfield;
apr_size_t len;
- apr_size_t name_len;
- apr_size_t val_len;
- char *next;
-
- name_len = strlen(fieldname);
- val_len = strlen(fieldval);
- len = name_len + val_len + 4; /* 4 for ": " plus CRLF */
- headfield = (char *)apr_palloc(h->pool, len + 1);
- memcpy(headfield, fieldname, name_len);
- next = headfield + name_len;
- *next++ = ':';
- *next++ = ' ';
- memcpy(next, fieldval, val_len);
- next += val_len;
- *next++ = CR;
- *next++ = LF;
- *next = 0;
+
+ headfield = apr_pstrcat(h->pool, fieldname, ": ", fieldval, CRLF, NULL);
+ len = strlen(headfield);
+
ap_xlate_proto_to_ascii(headfield, len);
apr_brigade_write(h->bb, NULL, NULL, headfield, len);
#else