Change usage string so that it matches the hget(1) manual page. Move the printing of u->postbody after the printing of cookies, since cookies must appear in the header. Add indentation to hhcrange(). Change setoffset() so that it sets out->written, and seeks to the appropriate file offset if the -o option is used. Without this, the assert(d >= 0) in output() fails and the output becomes garbage if the file was already partially downloaded. Reference: /n/sources/patch/applied/hget-setoffset-postbody Date: Wed Jun 15 12:47:25 CES 2005 --- /sys/src/cmd/hget.c Wed Jun 15 12:46:35 2005 +++ /sys/src/cmd/hget.c Wed Jun 15 12:46:13 2005 @@ -92,7 +92,7 @@ void usage(void) { - fprint(2, "usage: %s [-hv] [-o outfile] [-p body] [-x netmtpt] url\n", argv0); + fprint(2, "usage: %s [-dhv] [-o outfile] [-p body] [-x netmtpt] url\n", argv0); exits("usage"); } @@ -387,10 +387,8 @@ "Host: %s\r\n" "Content-type: application/x-www-form-urlencoded\r\n" "Content-length: %d\r\n" - "User-agent: Plan9/hget\r\n" - "\r\n", + "User-agent: Plan9/hget\r\n", u->page, u->host, strlen(u->postbody)); - dfprint(fd, "%s", u->postbody); } if(r->start != 0){ dfprint(fd, "Range: bytes=%d-\n", r->start); @@ -417,6 +415,8 @@ } dfprint(fd, "\r\n", u->host); + if(u->postbody) + dfprint(fd, "%s", u->postbody); auth = 0; redirect = 0; @@ -758,10 +758,11 @@ x = strchr(p, '/'); if(x) l = atoll(x+1); - if(l == 0) - x = strchr(p, '-'); - if(x) - l = atoll(x+1); + if(l == 0) { + x = strchr(p, '-'); + if(x) + l = atoll(x+1); + } if(l) r->end = l; } @@ -842,7 +843,7 @@ char conndir[NETPATHLEN]; char *p; - /* untested, proxy dosn't work with ftp (I think) */ + /* untested, proxy doesn't work with ftp (I think) */ if(px->host == nil){ ctl = dial(netmkaddr(u->host, tcpdir, u->port), 0, conndir, 0); } else { @@ -1417,6 +1418,10 @@ else out->curr = nil; out->offset = offset; + out->written = offset; + if(ofile != nil) + if(seek(out->fd, offset, 0) != offset) + sysfatal("seek: %r"); } /*