Skip to content

Instantly share code, notes, and snippets.

@zygm0nt
Forked from anonymous/mod_charset_lite.diff
Last active December 9, 2015 22:28
Show Gist options
  • Save zygm0nt/4337169 to your computer and use it in GitHub Desktop.
Save zygm0nt/4337169 to your computer and use it in GitHub Desktop.
Filter only content with mime types text/plain, text/html, application/* (to catch application/json)
--- mod_charset_lite.c.orig 2009-11-18 17:18:06.000000000 +0100
+++ mod_charset_lite.c 2013-01-14 13:11:45.017062580 +0100
@@ -239,9 +239,9 @@
}
/* catch proxy requests */
- if (r->proxyreq) {
+ /*if (r->proxyreq) {
return DECLINED;
- }
+ }*/
/* mod_rewrite indicators */
if (r->filename
@@ -814,7 +814,10 @@
if (!ctx->noop && ctx->xlate == NULL) {
const char *mime_type = f->r->content_type ? f->r->content_type : ap_default_type(f->r);
- if (strncasecmp(mime_type, "text/", 5) == 0 ||
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r,
+ "translating for %s", mime_type);
+
+ if ((strncasecmp(mime_type, "text/plain", 10) == 0 || strncasecmp(mime_type, "text/html", 9) == 0) ||
#if APR_CHARSET_EBCDIC
/* On an EBCDIC machine, be willing to translate mod_autoindex-
* generated output. Otherwise, it doesn't look too cool.
@@ -831,6 +834,7 @@
strcmp(mime_type, DIR_MAGIC_TYPE) == 0 ||
#endif
strncasecmp(mime_type, "message/", 8) == 0 ||
+ (strncasecmp(mime_type, "application/", 12) == 0 && strncasecmp(mime_type, "application/javascript", 22) != 0)||
dc->force_xlate == FX_FORCE) {
rv = apr_xlate_open(&ctx->xlate,
@zygm0nt
Copy link
Author

zygm0nt commented Dec 19, 2012

Diff for httpd-2.2.15-15.el6.centos.src.rpm

Alters ./modules/filters/mod_charset_lite.c so that it would work with proxied traffic, and with application/* content type - specifically needed for application/json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment