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/10/24 00:19:42 UTC

svn commit: r1187992 - /httpd/httpd/trunk/modules/filters/mod_filter.c

Author: sf
Date: Sun Oct 23 22:19:42 2011
New Revision: 1187992

URL: http://svn.apache.org/viewvc?rev=1187992&view=rev
Log:
Unbreak AddOutputFilterByType for content types of the form

  text/html;charset=...,

broken by r1171268. Add some trace logging

Modified:
    httpd/httpd/trunk/modules/filters/mod_filter.c

Modified: httpd/httpd/trunk/modules/filters/mod_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_filter.c?rev=1187992&r1=1187991&r2=1187992&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_filter.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_filter.c Sun Oct 23 22:19:42 2011
@@ -155,17 +155,28 @@ static int filter_lookup(ap_filter_t *f,
                               err);
                 match = 0;
             }
+            ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
+                          "Expression condition for '%s' %s",
+                          provider->frec->name,
+                          match ? "matched" : "did not match");
         }
         else if (r->content_type) {
             const char **type = provider->types;
             AP_DEBUG_ASSERT(type != NULL);
             while (*type) {
-                if (strcmp(*type, r->content_type) == 0) {
+                /* Handle 'content-type;charset=...' correctly */
+                size_t len = strcspn(r->content_type, "; \t");
+                if (strlen(*type) == len
+                    && strncmp(*type, r->content_type, len) == 0) {
                     match = 1;
                     break;
                 }
                 type++;
             }
+            ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
+                          "Content-Type condition for '%s' %s",
+                          provider->frec->name,
+                          match ? "matched" : "did not match");
         }
 
         if (match) {



Re: svn commit: r1187992 - /httpd/httpd/trunk/modules/filters/mod_filter.c

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 24 October 2011, Roy T. Fielding wrote:
> Wouldn't this be faster as
> 
>         else if (r->content_type) {
> +           /* Handle 'content-type;charset=...' correctly */
> +           size_t len = strcspn(r->content_type, "; \t");
>             const char **type = provider->types;
>             AP_DEBUG_ASSERT(type != NULL);
>             while (*type) {
> +                if ((strncmp(*type, r->content_type, len) == 0) &&
> +                    (*type[len] == '\0')) {
>                     match = 1;
>                     break;
>                 }
>                 type++;
>             }
> 
> or am I just trying to outwit the compiler?

Fixed. Thanks.

Re: svn commit: r1187992 - /httpd/httpd/trunk/modules/filters/mod_filter.c

Posted by "Roy T. Fielding" <fi...@gbiv.com>.
On Oct 23, 2011, at 3:19 PM, sf@apache.org wrote:

>         else if (r->content_type) {
>             const char **type = provider->types;
>             AP_DEBUG_ASSERT(type != NULL);
>             while (*type) {
> -                if (strcmp(*type, r->content_type) == 0) {
> +                /* Handle 'content-type;charset=...' correctly */
> +                size_t len = strcspn(r->content_type, "; \t");
> +                if (strlen(*type) == len
> +                    && strncmp(*type, r->content_type, len) == 0) {
>                     match = 1;
>                     break;
>                 }
>                 type++;
>             }

Wouldn't this be faster as

        else if (r->content_type) {
+           /* Handle 'content-type;charset=...' correctly */
+           size_t len = strcspn(r->content_type, "; \t");
            const char **type = provider->types;
            AP_DEBUG_ASSERT(type != NULL);
            while (*type) {
+                if ((strncmp(*type, r->content_type, len) == 0) &&
+                    (*type[len] == '\0')) {
                    match = 1;
                    break;
                }
                type++;
            }

or am I just trying to outwit the compiler?

....Roy