]> git.lizzy.rs Git - plan9front.git/blobdiff - rc/bin/hget
nusbrc: delect lenovo camera
[plan9front.git] / rc / bin / hget
index 82b9cba67ed8918a7bd395dc0a374a799a3b1824..ce258575bbf0977643f14e62018b6c978c471fa8 100755 (executable)
@@ -47,13 +47,24 @@ if(! ~ $#o 0){
        if(test -s $o)
                s=`{ls -l $o | awk '{print $6}'}
 }
-if(! ~ $s 0)
-       r=($r 'Range: bytes='^$s^'-')
 <[3=0] <>/mnt/web/clone {
        d=/mnt/web/^`{sed 1q}
        if(~ $#b 1)
                echo -n baseurl $b >[1=0]
        echo -n url $1 >[1=0]
+       if(! ~ $s 0 && ~ $#p 0 && ~ $#P 0 && ~ $#m 0){
+               for(i in $r)
+                       echo -n headers $i >[1=0]
+               echo -n request HEAD >[1=0]
+               <$d/body {
+                       if(~ $s `{cat $d/contentlength >[2]/dev/null})       
+                               exit ''
+               }
+               if(~ $#b 1)
+                       echo -n baseurl $b >[1=0]
+               echo -n url $1 >[1=0]
+               r=($r 'Range: bytes='^$s^'-')
+       }
        for(i in $r)
                echo -n headers $i >[1=0]
        if(~ $#m 1)
@@ -84,11 +95,11 @@ if(! ~ $s 0)
                c=`{cat $d/contentencoding >[2]/dev/null}
                switch($c){
                case *gzip*
-                       exec gunzip
+                       ~ `{cat $d/contenttype >[2]/dev/null} *gzip* || exec gunzip
                case *bzip2*
-                       exec bunzip2
+                       ~ `{cat $d/contenttype >[2]/dev/null} *bzip2* || exec bunzip2
                case *compress*
-                       exec uncompress
+                       ~ `{cat $d/contenttype >[2]/dev/null} *compress* || exec uncompress
                }
                exec cat
        }