Paul Slootman wrote:
> 
> Now, when trying it out, I find that it doesn't request compressed data,
> despite the "request-compressed-data = yes" option in the conf file.
> Yes, it's compiled with zlib support:
> 
...
> 
> With no proxy configured, I see this:
> 
> GET /something HTTP/1.1
> Host: 192.168.8.142:12345
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214
> Accept: 
>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
> Accept-Language: nl, en;q=0.50
> Accept-Encoding: gzip, deflate, compress;q=0.9
> Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
> Keep-Alive: 300
> Connection: keep-alive
> Cache-Control: max-age=0
> 
> Note that Mozilla is requesting compressed data.
> Now with wwwoffle configured as proxy:
> 
> GET /something HTTP/1.0
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214
> Accept: 
>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
> Accept-Language: nl, en;q=0.50
> Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
> Keep-Alive: 300
> Host: 192.168.8.142:12345
> Connection: close
> 
> The Accept-Encoding: line is not there...


Hello fellow countryman and namesake :-)

In the file parse.c I found the following lines of code which, I think, explain
what is going on:

/*+ Headers that are difficult with HTTP/1.1. +*/
static char *deleted_http11_headers[]={"If-Match",
                                       "If-Range",
                                       "Range",
                                       "Upgrade",
                                       "Accept-Encoding"};


And in the function ModifyRequest I found:

 /* Remove some headers */

 for(j=0;j<sizeof(deleted_http11_headers)/sizeof(char*);j++)
    RemoveFromHeader(request_head,deleted_http11_headers[j]);


The function ModifyRequest is called at lines 290 and 1485 of wwwoffles.c.
So it seems that the Accept-Encoding header line is first deleted from the
request.
But later, at line 1593, if correctly configured, WWWOFFLE adds its own version
back on:


#if USE_ZLIB
    if(ConfigBooleanURL(RequestCompressedData,Url) &&
!NotCompressed(NULL,Url->path))
      {
       request_compressed=1;
       AddToHeader(request_head,"Accept-Encoding","deflate; q=1.0, x-gzip; q=0.9, 
gzip; q=0.9, identity; q=0.1");
      }
#endif


The trouble is, that the request is written to the remote server at line 1496.
So the addition of the Accept-Encoding header line comes too late to do any
good.
I rearranged the code in wwwoffles.c a bit so the Accept-Encoding line is added
at what I think is the right moment. I've attached a patch file to this message
so you can try this for yourself.
I've tested my modification using a variation of your method; instead of your
shell script I used the following perl script:

#!/usr/bin/perl -w
use strict;

my @request_head=();
while (<>) {
    push @request_head,$_;
    if(/^[\r\n]*$/) {last}
}

print("HTTP/1.0 200 My-Echo-Server OK
Server: My-Echo-Server/1.0
Content-Type: text/plain

",@request_head);

exit 0;


This allows me to see the request head directly in my browser!


-- 
Paul A. Rombouts <[EMAIL PROTECTED]>
Vincent van Goghlaan 27
5246 GA  Rosmalen
Netherlands
--- wwwoffle.orig/wwwoffle-2.7/src/wwwoffles.c  Mon Feb  4 20:15:15 2002
+++ wwwoffle.myversion/wwwoffle-2.7/src/wwwoffles.c     Sat Feb 23 21:56:24 2002
@@ -108,6 +108,7 @@
 #if USE_ZLIB
  int client_compression=0;
  int server_compression=0;
+ int request_compressed=0;
 #endif
 
 
@@ -1489,11 +1490,23 @@
  if(mode==Fetch && client!=-1)
     write_formatted(client,"Fetching %s ...\n",Url->name);
 
- /* Write request to remote server. */
-
  if(mode==Real || mode==RealNoCache || mode==Fetch)
    {
-    char *err=(Url->Protocol->request)(Url,request_head,request_body);
+    char *err;
+
+    /* Add the compression header */
+
+#if USE_ZLIB
+    if(ConfigBooleanURL(RequestCompressedData,Url) && !NotCompressed(NULL,Url->path))
+      {
+       request_compressed=1;
+       AddToHeader(request_head,"Accept-Encoding","deflate; q=1.0, x-gzip; q=0.9, 
+gzip; q=0.9, identity; q=0.1");
+      }
+#endif
+
+    /* Write request to remote server. */
+
+    err=(Url->Protocol->request)(Url,request_head,request_body);
 
     /* In case of an error ... */
 
@@ -1580,18 +1593,7 @@
    {
     int server;
 #if USE_ZLIB
-    int request_compressed=0;
     char *content_encoding=NULL;
-#endif
-
-    /* Add the compression header */
-
-#if USE_ZLIB
-    if(ConfigBooleanURL(RequestCompressedData,Url) && !NotCompressed(NULL,Url->path))
-      {
-       request_compressed=1;
-       AddToHeader(request_head,"Accept-Encoding","deflate; q=1.0, x-gzip; q=0.9, 
gzip; q=0.9, identity; q=0.1");
-      }
 #endif
 
     /* Get the header */


Reply via email to