In GNU wget the --spider first issues a HEAD request, then if HEAD fails, issues a GET request.
In uclient, only a GET request is sent.
The patch changes GET to HEAD e.g. get the file size without downloading it first.
This is still not totally compatible with GNU wget because it does not retry with GET if HEAD fails.
Someone may use the --spider to call a GET only API, so they may be affected.
But this is incorrect usage while others may expect that the spider uses HEAD and don't expect a download.
Signed-off-by: Sungbo Eo <mans0n@gorani.run>
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
};
static const char *user_agent = "uclient-fetch";
+static const char *method = NULL;
static const char *post_data;
static const char *post_file;
static char opt_post = 0; /* 1 when --post-data/file is used */
msg_connecting(cl);
- rc = uclient_http_set_request_type(cl, opt_post ? "POST" : "GET");
+ rc = uclient_http_set_request_type(cl, method);
if (rc)
return rc;
}
}
+ if (opt_post == 1) {
+ method = "POST";
+ } else if (no_output) {
+ /* Note: GNU wget --spider sends a HEAD and if it failed repeats with a GET */
+ method = "HEAD";
+ } else {
+ method = "GET";
+ }
+
argv += optind;
argc -= optind;