@@ -47,6 +47,7 @@ static const char *post_file;
static struct ustream_ssl_ctx *ssl_ctx;
static const struct ustream_ssl_ops *ssl_ops;
static int quiet = false;
+static bool show_server_response = false;
static bool verify = true;
static bool proxy = true;
static bool default_certs = false;
@@ -478,6 +479,7 @@ static int usage(const char *progname)
" -O <file> Redirect output to file (use \"-\" for stdout)\n"
" -P <dir> Set directory for output files\n"
" --quiet | -q Turn off status messages\n"
+ " --server-response | -S Show response headers\n"
" --continue | -c Continue a partially-downloaded file\n"
" --user=<user> HTTP authentication username\n"
" --password=<password> HTTP authentication password\n"
@@ -550,6 +552,7 @@ enum {
L_PROXY,
L_NO_PROXY,
L_QUIET,
+ L_SERVER_RESPONSE,
};
static const struct option longopts[] = {
@@ -567,6 +570,7 @@ static const struct option longopts[] = {
[L_PROXY] = { "proxy", required_argument, NULL, 0 },
[L_NO_PROXY] = { "no-proxy", no_argument, NULL, 0 },
[L_QUIET] = { "quiet", no_argument, NULL, 0 },
+ [L_SERVER_RESPONSE] = { "server-response", no_argument, NULL, 0 },
{}
};
@@ -588,7 +592,7 @@ int main(int argc, char **argv)
signal(SIGPIPE, SIG_IGN);
init_ustream_ssl();
- while ((ch = getopt_long(argc, argv, "46cO:P:qsT:U:Y:", longopts, &longopt_idx)) != -1) {
+ while ((ch = getopt_long(argc, argv, "46cO:P:qSsT:U:Y:", longopts, &longopt_idx)) != -1) {
switch(ch) {
case 0:
switch (longopt_idx) {
@@ -651,6 +655,9 @@ int main(int argc, char **argv)
case L_QUIET:
quiet = true;
break;
+ case L_SERVER_RESPONSE:
+ show_server_response = true;
+ break;
default:
return usage(progname);
}
@@ -683,6 +690,9 @@ int main(int argc, char **argv)
case 's':
no_output = true;
break;
+ case 'S':
+ show_server_response = true;
+ break;
case 'T':
timeout = atoi(optarg);
break;
@@ -757,6 +757,9 @@ static void __uclient_notify_read(struct uclient_http *uh)
*sep = 0;
cur_len = next - data;
+// if (show_server_response) {
+ fprintf(stderr, " %s\n", data);
+// }
uclient_parse_http_line(uh, data);
if (seq != uh->seq)
return;
The -S is useful for debugging. With --spider or --method=HEAD it allows check size before download by Content-Length header. TODO currently the uclient-http must somehow to call a callback to print. Signed-off-by: Sergey Ponomarev <stokito@gmail.com> --- uclient-fetch.c | 12 +++++++++++- uclient-http.c | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-)