summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-04-30 22:09:57 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-04-30 22:09:57 +0200
commit9c79deb130cc64d12a567efbe372e366eb9a53fa (patch)
tree81b1336119887bdcd29c07d1c1587f3cb0cfb501
parenta2e26ffd4c8d65368503fb36ced68353e3cfdb52 (diff)
mothra: handle http compression out of band
-rw-r--r--sys/src/cmd/mothra/mothra.c22
-rw-r--r--sys/src/cmd/mothra/mothra.h2
-rw-r--r--sys/src/cmd/mothra/snoop.c3
3 files changed, 11 insertions, 16 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){
diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h
index 0531d826e..230f91c32 100644
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -52,8 +52,6 @@ enum{
BMP,
ICO,
- GUNZIP,
- COMPRESS,
PAGE,
};
diff --git a/sys/src/cmd/mothra/snoop.c b/sys/src/cmd/mothra/snoop.c
index 0e1a2108a..97b3c1f6d 100644
--- a/sys/src/cmd/mothra/snoop.c
+++ b/sys/src/cmd/mothra/snoop.c
@@ -102,9 +102,6 @@ snooptype(int fd)
"image/bmp", BMP,
"image/x-icon", ICO,
- "application/x-gzip", GUNZIP,
- "application/x-compress", COMPRESS,
-
"application/pdf", PAGE,
"application/postscript", PAGE,
"application/ghostscript", PAGE,