spdycat: Add --multiply option
This commit is contained in:
parent
ba8bc5cae7
commit
54d5dda6c4
|
@ -74,6 +74,7 @@ struct Config {
|
||||||
bool get_assets;
|
bool get_assets;
|
||||||
bool stat;
|
bool stat;
|
||||||
bool no_tls;
|
bool no_tls;
|
||||||
|
int multiply;
|
||||||
int spdy_version;
|
int spdy_version;
|
||||||
// milliseconds
|
// milliseconds
|
||||||
int timeout;
|
int timeout;
|
||||||
|
@ -83,7 +84,7 @@ struct Config {
|
||||||
std::map<std::string,std::string> headers;
|
std::map<std::string,std::string> headers;
|
||||||
std::string datafile;
|
std::string datafile;
|
||||||
Config():null_out(false), remote_name(false), verbose(false),
|
Config():null_out(false), remote_name(false), verbose(false),
|
||||||
get_assets(false), stat(false), no_tls(false),
|
get_assets(false), stat(false), no_tls(false), multiply(1),
|
||||||
spdy_version(-1), timeout(-1), window_bits(-1)
|
spdy_version(-1), timeout(-1), window_bits(-1)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
@ -299,6 +300,8 @@ struct SessionStat {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Config config;
|
||||||
|
|
||||||
struct SpdySession {
|
struct SpdySession {
|
||||||
std::vector<Request*> reqvec;
|
std::vector<Request*> reqvec;
|
||||||
// Map from stream ID to Request object.
|
// Map from stream ID to Request object.
|
||||||
|
@ -350,7 +353,9 @@ struct SpdySession {
|
||||||
if(path_cache.count(uri)) {
|
if(path_cache.count(uri)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
if(config.multiply == 1) {
|
||||||
path_cache.insert(uri);
|
path_cache.insert(uri);
|
||||||
|
}
|
||||||
reqvec.push_back(new Request(uri, u, data_prd, data_length, level));
|
reqvec.push_back(new Request(uri, u, data_prd, data_length, level));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +366,6 @@ struct SpdySession {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Config config;
|
|
||||||
extern bool ssl_debug;
|
extern bool ssl_debug;
|
||||||
|
|
||||||
void submit_request(Spdylay& sc, const std::string& hostport,
|
void submit_request(Spdylay& sc, const std::string& hostport,
|
||||||
|
@ -842,10 +846,12 @@ int run(char **uris, int n)
|
||||||
prev_host = get_uri_field(uri.c_str(), u, UF_HOST);
|
prev_host = get_uri_field(uri.c_str(), u, UF_HOST);
|
||||||
prev_port = port;
|
prev_port = port;
|
||||||
}
|
}
|
||||||
|
for(int j = 0; j < config.multiply; ++j) {
|
||||||
spdySession.add_request(uri, u, data_fd == -1 ? 0 : &data_prd,
|
spdySession.add_request(uri, u, data_fd == -1 ? 0 : &data_prd,
|
||||||
data_stat.st_size);
|
data_stat.st_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(!spdySession.reqvec.empty()) {
|
if(!spdySession.reqvec.empty()) {
|
||||||
spdySession.update_hostport();
|
spdySession.update_hostport();
|
||||||
if (communicate(prev_host, prev_port, spdySession, &callbacks) != 0) {
|
if (communicate(prev_host, prev_port, spdySession, &callbacks) != 0) {
|
||||||
|
@ -858,7 +864,7 @@ int run(char **uris, int n)
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
{
|
{
|
||||||
out << "Usage: spdycat [-Oadnsv23] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]\n"
|
out << "Usage: spdycat [-Oadnsv23] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]\n"
|
||||||
<< " [--key=<KEY>] [--no-tls] <URI>..."
|
<< " [--key=<KEY>] [--no-tls] [-m <N>] <URI>..."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,6 +900,9 @@ void print_help(std::ostream& out)
|
||||||
<< " SPDY protocol version to use.\n"
|
<< " SPDY protocol version to use.\n"
|
||||||
<< " -d, --data=<FILE> Post FILE to server. If - is given, data\n"
|
<< " -d, --data=<FILE> Post FILE to server. If - is given, data\n"
|
||||||
<< " will be read from stdin.\n"
|
<< " will be read from stdin.\n"
|
||||||
|
<< " -m, --multiply=<N> Request each URI <N> times. By default, same\n"
|
||||||
|
<< " URI is not requested twice. This option\n"
|
||||||
|
<< " disables it too.\n"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,10 +926,11 @@ int main(int argc, char **argv)
|
||||||
{"header", required_argument, 0, 'H' },
|
{"header", required_argument, 0, 'H' },
|
||||||
{"no-tls", no_argument, &flag, 3 },
|
{"no-tls", no_argument, &flag, 3 },
|
||||||
{"data", required_argument, 0, 'd' },
|
{"data", required_argument, 0, 'd' },
|
||||||
|
{"multiply", required_argument, 0, 'm' },
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int c = getopt_long(argc, argv, "Oad:nhH:v23st:w:", long_options,
|
int c = getopt_long(argc, argv, "Oad:m:nhH:v23st:w:", long_options,
|
||||||
&option_index);
|
&option_index);
|
||||||
if(c == -1) {
|
if(c == -1) {
|
||||||
break;
|
break;
|
||||||
|
@ -997,6 +1007,9 @@ int main(int argc, char **argv)
|
||||||
case 'd':
|
case 'd':
|
||||||
config.datafile = strcmp("-", optarg) == 0 ? "/dev/stdin" : optarg;
|
config.datafile = strcmp("-", optarg) == 0 ? "/dev/stdin" : optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
config.multiply = strtoul(optarg, 0, 10);
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
case 0:
|
case 0:
|
||||||
|
|
Loading…
Reference in New Issue