[zorp-hu] HTTP POST DATA elemzes (AnyPyProxy)

Gabor Burjan buga at buvoshetes.hu
2007. Május. 24., Cs, 10:23:48 CEST


Szia,

On Wed, May 23, 2007 at 11:00:01PM +0200, Viktor Tuska wrote:

> Van lehetoseg nem "chunked" modban kuldeni a stream-et?

A forrast bogaraszva nem igazan talaltunk ilyen lehetoseget, egy
tesztrendszeren a csatolt patch es policy segitsegevel sikerul
lebeszelni a zorpot az enchunkingrol.  Kerdeznem, hogy mennyire nyultam
melle a patch-csel :), illetve hogy terveztek-e ilyen feature-t a
kereskedelmi valtozatba.

buga
--------- következő rész ---------
diff -uwr /tmp/zorp-3.0.8/modules/http/http.c /home/buga/src/zorp-3.0.8/modules/http/http.c
--- /tmp/zorp-3.0.8/modules/http/http.c	2005-11-03 10:14:14.000000000 +0100
+++ /home/buga/src/zorp-3.0.8/modules/http/http.c	2007-05-24 09:52:16.000000000 +0200
@@ -181,6 +181,7 @@
   self->permit_proxy_requests = FALSE;
   self->permit_unicode_url = FALSE;
   self->permit_http09_responses = TRUE;
+  self->permit_enchunking = TRUE;
 
   self->rewrite_host_header = TRUE;
   self->require_host_header = TRUE;
@@ -526,6 +527,10 @@
                   Z_VAR_TYPE_INT | Z_VAR_GET | Z_VAR_SET_CONFIG | Z_VAR_GET_CONFIG,
                   &self->permit_http09_responses);
 
+  z_proxy_var_new(&self->super, "permit_enchunking",
+                  Z_VAR_TYPE_INT | Z_VAR_GET | Z_VAR_SET_CONFIG | Z_VAR_GET_CONFIG,
+                  &self->permit_enchunking);
+
   z_proxy_var_new(&self->super, "permit_both_connection_headers",
                   Z_VAR_TYPE_INT | Z_VAR_GET | Z_VAR_SET_CONFIG | Z_VAR_GET_CONFIG,
                   &self->permit_both_connection_headers);
diff -uwr /tmp/zorp-3.0.8/modules/http/httpfltr.c /home/buga/src/zorp-3.0.8/modules/http/httpfltr.c
--- /tmp/zorp-3.0.8/modules/http/httpfltr.c	2005-11-03 10:14:14.000000000 +0100
+++ /home/buga/src/zorp-3.0.8/modules/http/httpfltr.c	2007-05-24 09:54:07.000000000 +0200
@@ -894,7 +894,7 @@
                   self->content_length = owner->max_body_length;
                   self->force_nonpersistent_mode = TRUE;
                 }
-              if (owner->proto_version[to] > 0x0100 && owner->proto_version[from] > 0x0100)
+              if (owner->proto_version[to] > 0x0100 && owner->proto_version[from] > 0x0100 && owner->permit_enchunking)
                 {
                   /* The original entity is not chunked, we enchunk it to avoid bufferring and 
                    * keeping the connection open.
@@ -926,11 +926,22 @@
               
               if (self->content_length >= 0 || (expect_data && self->content_length == HTTP_LENGTH_UNKNOWN))
                 {
+		  if (owner->permit_enchunking)
+		    {
                   self->src_chunked = FALSE;
                   self->dst_chunked = TRUE;
                 }
               else
                 {
+                      if (owner->proto_version[from] >= 0x0100)                    
+                        self->persistent_with_cl_hint_only = TRUE;
+                      else
+                        self->force_nonpersistent_mode = TRUE;
+                      self->src_chunked = self->dst_chunked = FALSE;
+		    }
+                }
+              else
+                {
                   self->content_length = HTTP_LENGTH_NONE;
                 }
             }
diff -uwr /tmp/zorp-3.0.8/modules/http/http.h /home/buga/src/zorp-3.0.8/modules/http/http.h
--- /tmp/zorp-3.0.8/modules/http/http.h	2005-11-03 10:14:14.000000000 +0100
+++ /home/buga/src/zorp-3.0.8/modules/http/http.h	2007-05-24 09:53:38.000000000 +0200
@@ -309,6 +309,9 @@
   /* whether to permit HTTP/0.9 responses at all */
   gboolean permit_http09_responses;
   
+  /* whether to permit enchunking streams */
+  gboolean permit_enchunking;
+  
   /* whether to permit both Proxy-Connection and Connection headers in requests */
   gboolean permit_both_connection_headers;
   
diff -uwr /tmp/zorp-3.0.8/modules/http/Http.py /home/buga/src/zorp-3.0.8/modules/http/Http.py
--- /tmp/zorp-3.0.8/modules/http/Http.py	2005-11-03 10:14:15.000000000 +0100
+++ /home/buga/src/zorp-3.0.8/modules/http/Http.py	2007-05-24 09:53:08.000000000 +0200
@@ -406,6 +406,8 @@
                                          and only enable it when used in
                                          front of users.
                                          
+          permit_enchunking           -- [BOOLEAN:TRUE:RW:R] permit enchunking
+                                         
           permit_both_connection_headers -- [BOOLEAN:FALSE:RW:R] Some clients
                                          send both a Connection and a
                                          Proxy-Connection header, which is
--------- következő rész ---------
Egy nem text típusú csatolt állomány át lett konvertálva...
Név: policy.py
Típus: text/x-python
Méret: 1256 bytes
Leírás: nem elérhető
Url : http://lists.balabit.hu/pipermail/zorp-hu/attachments/20070524/d81f0ee7/policy.py


További információk a(z) zorp-hu levelezőlistáról