package w3m
tag 299462 patch
tag 208378 patch
thanks

This patch implements better support for Content-Encoding in w3m, so
that -dump-source and saving of files should work as expected.

Regards,
-- 
Karsten Schölzel        | Email:  [EMAIL PROTECTED]
Väderleden 9 4:98       | Jabber: [EMAIL PROTECTED]
97633 Luleå             | VoIP:   sip:[EMAIL PROTECTED]
Sweden                  |         sip:[EMAIL PROTECTED]
                        | Tel:    +4918015855857712
                        | Mobile: +46706725974
Decode Content-Encoding when
1) following a link and w3m wants to save the file
2) explicitly saving the file accessed by a link with SAVE_LINK.
Still to do: SAVE command and -dump-source

---
commit 4b44c159e8a8edddb085ed1b76befb495ad36143
tree fbfcd463f67beadfedf5deb12640b2a682a226a6
parent 488d2a9493ff726f5c23ec8cf8ac7148469dc23b
author Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 21:45:38 +0200
committer Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 21:45:38 +0200

 file.c |   12 ++++++++++++
 html.h |    1 +
 url.c  |    2 +-
 3 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/file.c b/file.c
index 7e861a2..3d1a97c 100644
--- a/file.c
+++ b/file.c
@@ -745,6 +745,7 @@ readHeader(URLFile *uf, Buffer *newBuf, 
                if (uf->compression != CMP_NOCOMPRESS)
                    break;
            }
+           uf->content_encoding = uf->compression;
        }
 #ifdef USE_COOKIE
        else if (use_cookie && accept_cookie &&
@@ -7797,6 +7798,7 @@ doFileSave(URLFile uf, char *defstr)
     char *p, *q;
     pid_t pid;
     char *lock;
+    char *tmpf = NULL; 
 #if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT))
     FILE *f;
 #endif
@@ -7837,6 +7839,11 @@ doFileSave(URLFile uf, char *defstr)
        flush_tty();
        pid = fork();
        if (!pid) {
+           if (uf.content_encoding != CMP_NOCOMPRESS) {
+               uncompress_stream(&uf, &tmpf);
+               if (tmpf)
+                   unlink(tmpf);
+           }
            setup_child(FALSE, 0, UFfileno(&uf));
            if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1)
                setModtime(p, uf.modtime);
@@ -7869,6 +7876,11 @@ doFileSave(URLFile uf, char *defstr)
            printf("Can't save. Load file and %s are identical.", p);
            return -1;
        }
+       if (uf.content_encoding != CMP_NOCOMPRESS) {
+           uncompress_stream(&uf, &tmpf);
+           if (tmpf)
+               unlink(tmpf);
+       }
        if (save2tmp(uf, p) < 0) {
            /* FIXME: gettextize? */
            printf("Can't save to %s\n", p);
diff --git a/html.h b/html.h
index 28d1599..705e9ee 100644
--- a/html.h
+++ b/html.h
@@ -69,6 +69,7 @@ typedef struct {
     InputStream stream;
     char *ext;
     int compression;
+    int content_encoding;
     char *guess_type;
 #ifdef USE_SSL
     char *ssl_certificate;
diff --git a/url.c b/url.c
index 9d8c5df..ec1cda1 100644
--- a/url.c
+++ b/url.c
@@ -1453,7 +1453,7 @@ init_stream(URLFile *uf, int scheme, Inp
     uf->scheme = scheme;
     uf->encoding = ENC_7BIT;
     uf->is_cgi = FALSE;
-    uf->compression = 0;
+    uf->compression = CMP_NOCOMPRESS;
     uf->guess_type = NULL;
     uf->ext = NULL;
     uf->modtime = -1;



!-------------------------------------------------------------flip-


If the file is transferred with Content-Encoding use a uncompressed version
as sourcefile. With this both -dump-source and SAVE work as expected.

---
commit 93726748970efa43ca71de264a682c1ea8aa70dd
tree a81af9d8e99bfd093863da8e75ced7f8c37d7d62
parent 4b44c159e8a8edddb085ed1b76befb495ad36143
author Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 22:46:54 +0200
committer Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 22:46:54 +0200

 file.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/file.c b/file.c
index 3d1a97c..d537c8d 100644
--- a/file.c
+++ b/file.c
@@ -2124,7 +2124,10 @@ loadGeneralFile(char *path, ParsedURL *v
        return NO_BUFFER;
     }
 
-    if (f.compression != CMP_NOCOMPRESS) {
+    if (f.content_encoding != CMP_NOCOMPRESS) {
+       uncompress_stream(&f, &pu.real_file);
+    }
+    else if (f.compression != CMP_NOCOMPRESS) {
        if (!(w3m_dump & DUMP_SOURCE) &&
            (w3m_dump & ~DUMP_FRAME || is_text_type(t)
             || searchExtViewer(t))) {



!-------------------------------------------------------------flip-


Forgot the initialization of content_encoding :-(

---
commit dd586d2f53a7917967602d22073484e0ad420a62
tree 8017d1908c1098ce9ce3f5ae005d7e62b847b384
parent 93726748970efa43ca71de264a682c1ea8aa70dd
author Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 23:55:43 +0200
committer Karsten Schoelzel <[EMAIL PROTECTED]> Mon, 01 May 2006 23:55:43 +0200

 url.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/url.c b/url.c
index ec1cda1..b34d535 100644
--- a/url.c
+++ b/url.c
@@ -1454,6 +1454,7 @@ init_stream(URLFile *uf, int scheme, Inp
     uf->encoding = ENC_7BIT;
     uf->is_cgi = FALSE;
     uf->compression = CMP_NOCOMPRESS;
+    uf->content_encoding = CMP_NOCOMPRESS;
     uf->guess_type = NULL;
     uf->ext = NULL;
     uf->modtime = -1;



!-------------------------------------------------------------flip-


Reply via email to