Added -3, --spdy3 option to spdycat.
This commit is contained in:
parent
036efc1018
commit
ae0bac563e
|
@ -61,7 +61,9 @@ struct Config {
|
|||
bool null_out;
|
||||
bool remote_name;
|
||||
bool verbose;
|
||||
Config():null_out(false), remote_name(false), verbose(false) {}
|
||||
bool spdy3_only;
|
||||
Config():null_out(false), remote_name(false), verbose(false),
|
||||
spdy3_only(false) {}
|
||||
};
|
||||
|
||||
struct Request {
|
||||
|
@ -145,6 +147,9 @@ int communicate(const std::string& host, uint16_t port,
|
|||
return -1;
|
||||
}
|
||||
std::string next_proto;
|
||||
if(config.spdy3_only) {
|
||||
next_proto = "spdy/3";
|
||||
}
|
||||
setup_ssl_ctx(ssl_ctx, &next_proto);
|
||||
SSL *ssl = SSL_new(ssl_ctx);
|
||||
if(!ssl) {
|
||||
|
@ -275,6 +280,8 @@ void print_help(std::ostream& out)
|
|||
<< " The filename is dereived from URI. If URI\n"
|
||||
<< " ends with '/', 'index.html' is used as a\n"
|
||||
<< " filename. Not implemented yet.\n"
|
||||
<< " -3, --spdy3 Only use SPDY/3.\n"
|
||||
<< "\n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
@ -285,11 +292,12 @@ int main(int argc, char **argv)
|
|||
{"verbose", no_argument, 0, 'v' },
|
||||
{"null-out", no_argument, 0, 'n' },
|
||||
{"remote-name", no_argument, 0, 'O' },
|
||||
{"spdy3", no_argument, 0, '3' },
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
int option_index = 0;
|
||||
int c = getopt_long(argc, argv, "Onhv", long_options, &option_index);
|
||||
int c = getopt_long(argc, argv, "Onhv3", long_options, &option_index);
|
||||
if(c == -1) {
|
||||
break;
|
||||
}
|
||||
|
@ -306,6 +314,9 @@ int main(int argc, char **argv)
|
|||
case 'v':
|
||||
config.verbose = true;
|
||||
break;
|
||||
case '3':
|
||||
config.spdy3_only = true;
|
||||
break;
|
||||
case '?':
|
||||
exit(EXIT_FAILURE);
|
||||
default:
|
||||
|
|
|
@ -470,14 +470,19 @@ int select_next_proto_cb(SSL* ssl,
|
|||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
std::string& next_proto = *(std::string*)arg;
|
||||
if(next_proto.empty()) {
|
||||
if(spdylay_select_next_protocol(out, outlen, in, inlen) != 1) {
|
||||
std::cerr << "Server did not advertise spdy/2 or spdy/3 protocol."
|
||||
<< std::endl;
|
||||
abort();
|
||||
} else {
|
||||
std::string& next_proto = *(std::string*)arg;
|
||||
next_proto.assign(&(*out)[0], &(*out)[*outlen]);
|
||||
}
|
||||
} else {
|
||||
*out = (unsigned char*)(next_proto.c_str());
|
||||
*outlen = next_proto.size();
|
||||
}
|
||||
if(ssl_debug) {
|
||||
std::cout << " NPN selected the protocol: "
|
||||
<< std::string((const char*)*out, (size_t)*outlen) << std::endl;
|
||||
|
|
Loading…
Reference in New Issue