add support for PUT requests
[project/uclient.git] / uclient-example.c
index 144696c00fd94a1c3f6486e07bdeb3197d9e3e58..49d18847a244a4b4ca6693f3d5e1cc9d14fe1b54 100644 (file)
@@ -86,7 +86,7 @@ static int open_output_file(const char *path, bool create)
 
 static void request_done(struct uclient *cl)
 {
-       if (output_fd >= 0) {
+       if (output_fd >= 0 && !output_file) {
                close(output_fd);
                output_fd = -1;
        }
@@ -224,6 +224,7 @@ static int usage(const char *progname)
        fprintf(stderr,
                "Usage: %s [options] <URL>\n"
                "Options:\n"
+               "       -q:                             Turn off status messages\n"
                "       -O <file>:                      Redirect output to file (use \"-\" for stdout)\n"
                "\n"
                "HTTPS options:\n"
@@ -327,6 +328,9 @@ int main(int argc, char **argv)
 
        uclient_free(cl);
 
+       if (output_fd >= 0 && output_fd != STDOUT_FILENO)
+               close(output_fd);
+
        if (ssl_ctx)
                ssl_ops->context_free(ssl_ctx);