h2load: add --connect-to option

This commit is contained in:
lucas 2019-12-12 16:33:34 +00:00 committed by Tatsuhiro Tsujikawa
parent 1fff737955
commit df575f968f
2 changed files with 13 additions and 2 deletions

View File

@ -1563,8 +1563,11 @@ void resolve_host() {
hints.ai_protocol = 0;
hints.ai_flags = AI_ADDRCONFIG;
rv = getaddrinfo(config.host.c_str(), util::utos(config.port).c_str(), &hints,
&res);
const auto &resolve_host =
config.connect_to_host.empty() ? config.host : config.connect_to_host;
rv = getaddrinfo(resolve_host.c_str(), util::utos(config.port).c_str(),
&hints, &res);
if (rv != 0) {
std::cerr << "getaddrinfo() failed: " << gai_strerror(rv) << std::endl;
exit(EXIT_FAILURE);
@ -1979,6 +1982,8 @@ Options:
response time when using one worker thread, but may
appear slightly out of order with multiple threads due
to buffering. Status code is -1 for failed streams.
--connect-to=<HOST>
Host to connect instead of using the host in <URI>.
-v, --verbose
Output debug information.
--version Display version information and exit.
@ -2037,6 +2042,7 @@ int main(int argc, char **argv) {
{"encoder-header-table-size", required_argument, &flag, 8},
{"warm-up-time", required_argument, &flag, 9},
{"log-file", required_argument, &flag, 10},
{"connect-to", required_argument, &flag, 11},
{nullptr, 0, nullptr, 0}};
int option_index = 0;
auto c = getopt_long(argc, argv,
@ -2264,6 +2270,10 @@ int main(int argc, char **argv) {
// --log-file
logfile = optarg;
break;
case 11:
// --connect-to
config.connect_to_host = optarg;
break;
}
break;
default:

View File

@ -69,6 +69,7 @@ struct Config {
nghttp2::Headers custom_headers;
std::string scheme;
std::string host;
std::string connect_to_host;
std::string ifile;
std::string ciphers;
// length of upload data