tool: add --unix-socket option

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Peter Wu 2014-11-27 23:59:26 +01:00 committed by Daniel Stenberg
parent 970c22f970
commit c8644d1f63
5 changed files with 11 additions and 0 deletions

View File

@ -115,6 +115,7 @@ static void free_config_fields(struct OperationConfig *config)
Curl_safefree(config->xoauth2_bearer); Curl_safefree(config->xoauth2_bearer);
Curl_safefree(config->unix_socket_path);
Curl_safefree(config->writeout); Curl_safefree(config->writeout);
curl_slist_free_all(config->quote); curl_slist_free_all(config->quote);

View File

@ -204,6 +204,7 @@ struct OperationConfig {
char *xoauth2_bearer; /* XOAUTH2 bearer token */ char *xoauth2_bearer; /* XOAUTH2 bearer token */
bool nonpn; /* enable/disable TLS NPN extension */ bool nonpn; /* enable/disable TLS NPN extension */
bool noalpn; /* enable/disable TLS ALPN extension */ bool noalpn; /* enable/disable TLS ALPN extension */
char *unix_socket_path; /* path to UNIX domain socket */
struct GlobalConfig *global; struct GlobalConfig *global;
struct OperationConfig *prev; struct OperationConfig *prev;

View File

@ -176,6 +176,7 @@ static const struct LongShort aliases[]= {
{"$J", "metalink", FALSE}, {"$J", "metalink", FALSE},
{"$K", "sasl-ir", FALSE}, {"$K", "sasl-ir", FALSE},
{"$L", "test-event", FALSE}, {"$L", "test-event", FALSE},
{"$M", "unix-socket", TRUE},
{"0", "http1.0", FALSE}, {"0", "http1.0", FALSE},
{"01", "http1.1", FALSE}, {"01", "http1.1", FALSE},
{"02", "http2", FALSE}, {"02", "http2", FALSE},
@ -976,6 +977,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
warnf(config, "--test-event is ignored unless a debug build!\n"); warnf(config, "--test-event is ignored unless a debug build!\n");
#endif #endif
break; break;
case 'M': /* --unix-socket */
GetStr(&config->unix_socket_path, nextarg);
break;
} }
break; break;
case '#': /* --progress-bar */ case '#': /* --progress-bar */

View File

@ -231,6 +231,7 @@ static const char *const helptext[] = {
" --tlsuser USER TLS username", " --tlsuser USER TLS username",
" --tlspassword STRING TLS password", " --tlspassword STRING TLS password",
" --tlsauthtype STRING TLS authentication type (default: SRP)", " --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)", " -A, --user-agent STRING Send User-Agent STRING to server (H)",
" -v, --verbose Make the operation more talkative", " -v, --verbose Make the operation more talkative",
" -V, --version Show version number and quit", " -V, --version Show version number and quit",

View File

@ -1331,6 +1331,10 @@ static CURLcode operate_do(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_SSL_ENABLE_ALPN, 0L); 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 */ /* initialize retry vars for loop below */
retry_sleep_default = (config->retry_delay) ? retry_sleep_default = (config->retry_delay) ?
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */ config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */