]> pd.if.org Git - zpackage/commitdiff
change http header output
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 5 Mar 2019 16:34:02 +0000 (16:34 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 5 Mar 2019 16:34:02 +0000 (16:34 +0000)
doc/zpm-fetchurl.8
src/fetchurl.c

index b152f611fe410372d4cfcf254086153d2b5f856b..d5487e5908eee133a29dbdd99140b2cb512677e6 100644 (file)
@@ -14,6 +14,7 @@ zpm-fetchurl \- download files
 ]
 [
 .BI \-U " useragent"
+]
 [
 .BI -o file
 ]
@@ -29,10 +30,14 @@ used.
 While this program can be used directly, it is intended for use by zpm scripts
 for downloading repositories and packages without requiring an external
 dependency.
+.PP
+URLs of the file scheme have an http style response header generated
+internally so the same code and output are used.
 .SH OPTIONS
 .TP
 .B \-I
-output the response header only, implies -r
+output the response header only, implies \-r.  The output file
+is ignored and the header is written to stdout.
 .TP
 .B \-r
 output the entire response, including the header
@@ -74,11 +79,16 @@ Fail silently on errors.
 .TP
 .B \-p \-#
 Output a progress bar.  A '#' is accepted for compatibility with curl.
+.TP
+.BI \-U " useragent"
+Set the User-Agent header to \fIuseragent\fR.
 .SH EXAMPLES
 .TP
 zpm fetchurl -o zpm-0.1.2.zpm https://zoranix.net/repo/packages/zpm-0.1.2.zpm
 .SH EXIT STATUS
 0 on success non zero on failure
+.PP
+Failure is any exit status code >= 400.
 .SH FILES
 /var/lib/zpm/known_hosts
 ~/.zpm/known_hosts
index afce2cdf132b68594622588b23f83bafdaf0248f..f4ae8da2779e9b63152ddbc0fde7f0027d79afe5 100644 (file)
@@ -957,6 +957,12 @@ int main(int ac, char *av[]) {
 
                if (head) {
                        io.response.len -= 2;
+                       write(out, io.response.buffer, io.response.len);
+                       break;
+               }
+
+               if (io.status_code == 304) {
+                       break;
                }
 
                if (outfile) {
@@ -973,11 +979,6 @@ int main(int ac, char *av[]) {
                        }
                }
 
-               if (head) {
-                       write(out, io.response.buffer, io.response.len);
-                       break;
-               }
-
                if (raw) {
                        write(out, io.response.buffer, header_len);
                }