Skip to content

Commit 3a59bfd

Browse files
committed
Use mapcache_util_str_replace_all
1 parent 5cf2551 commit 3a59bfd

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

cgi/mapcache.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,6 @@ static void fcgi_write_response(mapcache_context_fcgi *ctx, mapcache_http_respon
162162
}
163163
}
164164

165-
// Replace all occurrences of substr in string
166-
char* str_replace_all(apr_pool_t* pool, const char* string,
167-
const char* substr, const char* replacement)
168-
{
169-
char* replaced = apr_pstrdup(pool, string);
170-
while (strstr(replaced, substr)) {
171-
replaced = mapcache_util_str_replace(pool, string, substr, replacement);
172-
}
173-
return replaced;
174-
}
175-
176165
apr_time_t mtime;
177166
char *conffile;
178167

@@ -264,8 +253,7 @@ static void set_headers(mapcache_context* ctx, char** env)
264253
// convert HTTP header keys from the form HTTP_MY_HEADER to MY-HEADER
265254
key = apr_strtok(kvp, "=", &pair);
266255
key = mapcache_util_str_replace(ctx->pool, key, "HTTP_", "");
267-
key = mapcache_util_str_replace(ctx->pool, key, "_", "-");
268-
// key = str_replace_all(ctx->pool, key, "_", "-");
256+
key = mapcache_util_str_replace_all(ctx->pool, key, "_", "-");
269257
val = apr_strtok(NULL, "=", &pair);
270258

271259
if (val != NULL) {
@@ -348,7 +336,7 @@ int main(int argc, const char **argv)
348336
goto cleanup;
349337
}
350338

351-
set_headers(ctx, environ);
339+
set_headers(ctx, apr_pstrdup(ctx->pool, environ));
352340

353341
http_response = NULL;
354342
if(request->type == MAPCACHE_REQUEST_GET_CAPABILITIES) {

0 commit comments

Comments
 (0)