curl-library
[PATCH 11/11] tool: add --unix-socket option
From: Peter Wu <peter_at_lekensteyn.nl>
Date: Thu, 27 Nov 2014 23:59:26 +0100
Date: Thu, 27 Nov 2014 23:59:26 +0100
Signed-off-by: Peter Wu <peter_at_lekensteyn.nl>
--- src/tool_cfgable.c | 1 + src/tool_cfgable.h | 1 + src/tool_getparam.c | 8 ++++++++ src/tool_help.c | 1 + src/tool_operate.c | 4 ++++ 5 files changed, 15 insertions(+) diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c index bd8707e..1a378f0 100644 --- a/src/tool_cfgable.c +++ b/src/tool_cfgable.c @@ -114,6 +114,7 @@ static void free_config_fields(struct OperationConfig *config) Curl_safefree(config->xoauth2_bearer); + Curl_safefree(config->unix_socket_path); Curl_safefree(config->writeout); curl_slist_free_all(config->quote); diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 11a6a98..2336016 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -204,6 +204,7 @@ struct OperationConfig { char *xoauth2_bearer; /* XOAUTH2 bearer token */ bool nonpn; /* enable/disable TLS NPN extension */ bool noalpn; /* enable/disable TLS ALPN extension */ + char *unix_socket_path; /* path to UNIX domain socket */ struct GlobalConfig *global; struct OperationConfig *prev; diff --git a/src/tool_getparam.c b/src/tool_getparam.c index bf025e4..9a82518 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -176,6 +176,7 @@ static const struct LongShort aliases[]= { {"$J", "metalink", FALSE}, {"$K", "sasl-ir", FALSE}, {"$L", "test-event", FALSE}, + {"$M", "unix-socket", TRUE}, {"0", "http1.0", FALSE}, {"01", "http1.1", FALSE}, {"02", "http2", FALSE}, @@ -976,6 +977,13 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ warnf(config, "--test-event is ignored unless a debug build!\n"); #endif break; + case 'M': /* --unix-socket */ +#ifdef USE_UNIX_SOCKETS + GetStr(&config->unix_socket_path, nextarg); +#else + warnf(config, "--unix-socket is not available on this platform!\n"); +#endif + break; } break; case '#': /* --progress-bar */ diff --git a/src/tool_help.c b/src/tool_help.c index 6f8f292..3d16e0f 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -231,6 +231,7 @@ static const char *const helptext[] = { " --tlsuser USER TLS username", " --tlspassword STRING TLS password", " --tlsauthtype STRING TLS authentication type (default: SRP)", + " --unix-socket FILE Connect through this UNIX domain socket", " -A, --user-agent STRING Send User-Agent STRING to server (H)", " -v, --verbose Make the operation more talkative", " -V, --version Show version number and quit", diff --git a/src/tool_operate.c b/src/tool_operate.c index fe54a34..43d6ec3 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1331,6 +1331,10 @@ static CURLcode operate_do(struct GlobalConfig *global, my_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L); } + /* new in 7.40.0 */ + if(config->unix_socket_path) + my_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, config->unix_socket_path); + /* initialize retry vars for loop below */ retry_sleep_default = (config->retry_delay) ? config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */ -- 2.1.3 ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2014-11-28