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