r3951 - in branches/gzip/varnish-cache: bin/varnishd include lib/libvcl

sky at projects.linpro.no sky at projects.linpro.no
Wed Mar 18 14:05:17 CET 2009


Author: sky
Date: 2009-03-18 14:05:17 +0100 (Wed, 18 Mar 2009)
New Revision: 3951

Modified:
   branches/gzip/varnish-cache/bin/varnishd/cache.h
   branches/gzip/varnish-cache/bin/varnishd/cache_vrt.c
   branches/gzip/varnish-cache/include/vrt_obj.h
   branches/gzip/varnish-cache/lib/libvcl/vcc_fixed_token.c
   branches/gzip/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   branches/gzip/varnish-cache/lib/libvcl/vcc_obj.c
Log:
allow you to indicate what kind of compression the client wants

Modified: branches/gzip/varnish-cache/bin/varnishd/cache.h
===================================================================
--- branches/gzip/varnish-cache/bin/varnishd/cache.h	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/bin/varnishd/cache.h	2009-03-18 13:05:17 UTC (rev 3951)
@@ -106,6 +106,13 @@
 	char			*e;
 } txt;
 
+
+enum compression {
+	HTTP_COMPRESSION_NONE,
+	HTTP_COMPRESSION_GZIP,
+	HTTP_COMPRESSION_DEFLATE
+};
+
 /*--------------------------------------------------------------------*/
 
 enum step {
@@ -414,6 +421,8 @@
 	unsigned		ihashptr;
 	unsigned		lhashptr;
 	const char		**hashptr;
+
+	enum compression        compression;
 };
 
 

Modified: branches/gzip/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/gzip/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-18 13:05:17 UTC (rev 3951)
@@ -603,7 +603,49 @@
 }
 
 /*--------------------------------------------------------------------*/
+void
+VRT_l_client_gzip(struct sess *sp, unsigned enabled) {
+	if (enabled > 0) 
+		sp->compression = HTTP_COMPRESSION_GZIP;
+	else
+		sp->compression = HTTP_COMPRESSION_NONE;
+}
 
+unsigned
+VRT_r_client_gzip(struct sess *sp) {
+	if (sp->compression == HTTP_COMPRESSION_GZIP)
+		return 1;
+	else
+		return 0;
+}
+
+void
+VRT_l_client_deflate(struct sess *sp, unsigned enabled) {
+	if (enabled > 0) 
+		sp->compression = HTTP_COMPRESSION_DEFLATE;
+	else
+		sp->compression = HTTP_COMPRESSION_NONE;
+}
+
+unsigned
+VRT_r_client_deflate(struct sess *sp) {
+	if (sp->compression == HTTP_COMPRESSION_DEFLATE)
+		return 1;
+	else
+		return 0;
+}
+
+const char*
+VRT_r_client_compression(const struct sess *sp) {
+	if (sp->compression == HTTP_COMPRESSION_NONE)
+		return "";
+	else if (sp->compression == HTTP_COMPRESSION_GZIP)
+		return "gzip";
+	else
+		return "deflate";
+		
+}
+
 struct sockaddr *
 VRT_r_client_ip(const struct sess *sp)
 {

Modified: branches/gzip/varnish-cache/include/vrt_obj.h
===================================================================
--- branches/gzip/varnish-cache/include/vrt_obj.h	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/include/vrt_obj.h	2009-03-18 13:05:17 UTC (rev 3951)
@@ -7,6 +7,11 @@
  */
 
 struct sockaddr * VRT_r_client_ip(const struct sess *);
+unsigned VRT_r_client_gzip(struct sess *);
+void VRT_l_client_gzip(struct sess *, unsigned);
+unsigned VRT_r_client_deflate(struct sess *);
+void VRT_l_client_deflate(struct sess *, unsigned);
+const char * VRT_r_client_compression(const struct sess *);
 struct sockaddr * VRT_r_server_ip(struct sess *);
 const char * VRT_r_server_hostname(struct sess *);
 const char * VRT_r_server_identity(struct sess *);

Modified: branches/gzip/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/gzip/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-18 13:05:17 UTC (rev 3951)
@@ -159,10 +159,10 @@
 
 	/* ../../include/vcl.h */
 
-	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3781 2009-02-17 10");
-	vsb_cat(sb, ":29:20Z phk $\n *\n * NB:  This file is machine genera");
-	vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
-	vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3948 2009-03-18 11");
+	vsb_cat(sb, ":25:43Z kristian $\n *\n * NB:  This file is machine g");
+	vsb_cat(sb, "enerated, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fi");
+	vsb_cat(sb, "xed_token.tcl instead\n */\n\nstruct sess;\n");
 	vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");
 	vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n");
 	vsb_cat(sb, "typedef int vcl_func_f(struct sess *sp);\n");
@@ -326,11 +326,14 @@
 	vsb_cat(sb, " *\n * NB:  This file is machine generated, DO NOT EDI");
 	vsb_cat(sb, "T!\n *\n * Edit vcc_gen_obj.tcl instead\n");
 	vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
-	vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
-	vsb_cat(sb, "s *);\n<<<<<<< .mine\nconst char * VRT_r_server_hostna");
-	vsb_cat(sb, "me(struct sess *);\nconst char * VRT_r_server_identity");
-	vsb_cat(sb, "(struct sess *);\n=======\nconst char * VRT_r_server_h");
-	vsb_cat(sb, "ostname(struct sess *);\n>>>>>>> .r3947\n");
+	vsb_cat(sb, "sess *);\nunsigned VRT_r_client_gzip(struct sess *);\n");
+	vsb_cat(sb, "void VRT_l_client_gzip(struct sess *, unsigned);\n");
+	vsb_cat(sb, "unsigned VRT_r_client_deflate(struct sess *);\n");
+	vsb_cat(sb, "void VRT_l_client_deflate(struct sess *, unsigned);\n");
+	vsb_cat(sb, "const char * VRT_r_client_compression(const struct ses");
+	vsb_cat(sb, "s *);\nstruct sockaddr * VRT_r_server_ip(struct sess *");
+	vsb_cat(sb, ");\nconst char * VRT_r_server_hostname(struct sess *);");
+	vsb_cat(sb, "\nconst char * VRT_r_server_identity(struct sess *);\n");
 	vsb_cat(sb, "int VRT_r_server_port(struct sess *);\n");
 	vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
 	vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char");

Modified: branches/gzip/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- branches/gzip/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-18 13:05:17 UTC (rev 3951)
@@ -46,6 +46,21 @@
 	{ }
 	"const struct sess *"
     }
+    { client.gzip
+	RW BOOL
+	{recv pipe pass hash miss hit fetch deliver                error }
+	"struct sess *"
+    }
+    { client.deflate
+	RW BOOL
+	{recv pipe pass hash miss hit fetch deliver                error }
+	"struct sess *"
+    }
+    { client.compression
+	RO STRING
+	{recv pipe pass hash miss hit fetch deliver                error }
+	"const struct sess *"
+    }
     { server.ip
 	RO IP
 	{recv pipe pass hash miss hit fetch deliver                error }

Modified: branches/gzip/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- branches/gzip/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-18 12:17:00 UTC (rev 3950)
+++ branches/gzip/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-18 13:05:17 UTC (rev 3951)
@@ -18,6 +18,27 @@
 	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
 	     | VCL_MET_ERROR
 	},
+	{ "client.gzip", BOOL, 11,
+	    "VRT_r_client_gzip(sp)",	    "VRT_l_client_gzip(sp, ",
+	    V_RW,	    0,
+	    VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+	     | VCL_MET_ERROR
+	},
+	{ "client.deflate", BOOL, 14,
+	    "VRT_r_client_deflate(sp)",	    "VRT_l_client_deflate(sp, ",
+	    V_RW,	    0,
+	    VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+	     | VCL_MET_ERROR
+	},
+	{ "client.compression", STRING, 18,
+	    "VRT_r_client_compression(sp)",	    NULL,
+	    V_RO,	    0,
+	    VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+	     | VCL_MET_ERROR
+	},
 	{ "server.ip", IP, 9,
 	    "VRT_r_server_ip(sp)",	    NULL,
 	    V_RO,	    0,



More information about the varnish-commit mailing list