Add an enable-compression directive and disable compression by default
authorFabian Keil <fk@fabiankeil.de>
Fri, 8 Jul 2011 13:30:08 +0000 (13:30 +0000)
committerFabian Keil <fk@fabiankeil.de>
Fri, 8 Jul 2011 13:30:08 +0000 (13:30 +0000)
loadcfg.c
parsers.c
project.h

index e4e6f65..ac86848 100644 (file)
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -1,4 +1,4 @@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.115 2011/07/08 13:29:22 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.116 2011/07/08 13:29:39 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@ -140,6 +140,7 @@ static struct file_list *current_configfile = NULL;
 #define hash_default_server_timeout      2530089913ul /* "default-server-timeout" */
 #define hash_deny_access                 1227333715ul /* "deny-access" */
 #define hash_enable_edit_actions         2517097536ul /* "enable-edit-actions" */
+#define hash_enable_compression          3943696946ul /* "enable-compression" */
 #define hash_enable_remote_toggle        2979744683ul /* "enable-remote-toggle" */
 #define hash_enable_remote_http_toggle    110543988ul /* "enable-remote-http-toggle" */
 #define hash_enforce_blocks              1862427469ul /* "enforce-blocks" */
@@ -411,6 +412,7 @@ struct configuration_spec * load_config(void)
    config->feature_flags            &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
    config->feature_flags            &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
 #ifdef FEATURE_COMPRESSION
+   config->feature_flags            &= ~RUNTIME_FEATURE_COMPRESSION;
    /*
     * XXX: Run some benchmarks to see if there are better default values.
     */
@@ -721,6 +723,23 @@ struct configuration_spec * load_config(void)
             break;
 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
 
+/* *************************************************************************
+ * enable-compression 0|1
+ * *************************************************************************/
+#ifdef FEATURE_COMPRESSION
+         case hash_enable_compression:
+            if (parse_toggle_state(cmd, arg) == 1)
+            {
+               config->feature_flags |= RUNTIME_FEATURE_COMPRESSION;
+            }
+            else
+            {
+               config->feature_flags &= ~RUNTIME_FEATURE_COMPRESSION;
+            }
+            break;
+#endif /* def FEATURE_COMPRESSION */
+
+
 /* *************************************************************************
  * enable-remote-toggle 0|1
  * *************************************************************************/
index a973078..fc8f6c9 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.223 2011/06/23 13:57:47 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.224 2011/06/23 14:01:01 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -2620,7 +2620,8 @@ static jb_err server_last_modified(struct client_state *csp, char **header)
 static jb_err client_accept_encoding(struct client_state *csp, char **header)
 {
 #ifdef FEATURE_COMPRESSION
-   if (strstr(*header, "deflate"))
+   if ((csp->config->feature_flags & RUNTIME_FEATURE_COMPRESSION)
+      && strstr(*header, "deflate"))
    {
       csp->flags |= CSP_FLAG_CLIENT_SUPPORTS_DEFLATE;
    }
index d524be0..37cfc41 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.167 2011/07/03 17:55:23 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.168 2011/07/08 13:27:31 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
@@ -1190,6 +1190,9 @@ struct access_control_list
 /** configuration_spec::feature_flags: Pages blocked with +handle-as-empty-doc get a return status of 200 OK. */
 #define RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK       512U
 
+/** configuration_spec::feature_flags: Buffered content is sent compressed if the client supports it. */
+#define RUNTIME_FEATURE_COMPRESSION               1024U
+
 /**
  * Data loaded from the configuration file.
  *