diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-04-30 22:09:57 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-04-30 22:09:57 +0200 |
commit | 9c79deb130cc64d12a567efbe372e366eb9a53fa (patch) | |
tree | 81b1336119887bdcd29c07d1c1587f3cb0cfb501 /sys/src/cmd/mothra/mothra.c | |
parent | a2e26ffd4c8d65368503fb36ced68353e3cfdb52 (diff) |
mothra: handle http compression out of band
Diffstat (limited to 'sys/src/cmd/mothra/mothra.c')
-rw-r--r-- | sys/src/cmd/mothra/mothra.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index c56630ba2..5ffc74018 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -825,6 +825,7 @@ int readstr(char *buf, int nbuf, char *base, char *name){ int urlopen(Url *url, int method, char *body){ int conn, ctlfd, fd, n; char buf[1024+1], *p; + char encoding[64]; if(debug) fprint(2, "urlopen %s (%s)\n", url->reltext, url->basename); @@ -863,11 +864,19 @@ int urlopen(Url *url, int method, char *body){ } snprint(buf, sizeof buf, "%s/%d/body", mtpt, conn); if((fd = open(buf, OREAD)) < 0) - goto ErrOut; + goto ErrOut; snprint(buf, sizeof buf, "%s/%d/parsed", mtpt, conn); readstr(url->fullname, sizeof(url->fullname), buf, "url"); readstr(url->tag, sizeof(url->tag), buf, "fragment"); + snprint(buf, sizeof buf, "%s/%d", mtpt, conn); + readstr(encoding, sizeof(encoding), buf, "contentencoding"); close(ctlfd); + if(!cistrcmp(encoding, "compress")) + fd = pipeline("/bin/uncompress", fd); + else if(!cistrcmp(encoding, "gzip")) + fd = pipeline("/bin/gunzip", fd); + else if(!cistrcmp(encoding, "bzip2")) + fd = pipeline("/bin/bunzip2", fd); return fd; } @@ -955,17 +964,8 @@ void geturl(char *urlname, int method, char *body, int plumb, int map){ message("getting %s", selection->fullname); if(mothmode && !plumb) typ = -1; - else { + else typ = snooptype(fd); - if(typ == GUNZIP){ - fd=pipeline("/bin/gunzip", fd); - typ = snooptype(fd); - } - if(typ == COMPRESS){ - fd=pipeline("/bin/uncompress", fd); - typ = snooptype(fd); - } - } switch(typ){ default: if(plumb){ |