Check Return non-zero for failed spdy requests.
This commit is contained in:
parent
8fd2fabef8
commit
ac7b87c7a5
|
@ -161,10 +161,13 @@ int communicate(const std::string& host, uint16_t port,
|
||||||
}
|
}
|
||||||
make_non_block(fd);
|
make_non_block(fd);
|
||||||
set_tcp_nodelay(fd);
|
set_tcp_nodelay(fd);
|
||||||
Spdylay sc(fd, ssl,
|
int spdy_version = spdylay_npn_get_version(
|
||||||
spdylay_npn_get_version(reinterpret_cast<const unsigned char*>
|
reinterpret_cast<const unsigned char*>(next_proto.c_str()),
|
||||||
(next_proto.c_str()), next_proto.size()),
|
next_proto.size());
|
||||||
callbacks);
|
if (spdy_version <= 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Spdylay sc(fd, ssl, spdy_version, callbacks);
|
||||||
|
|
||||||
nfds_t npollfds = 1;
|
nfds_t npollfds = 1;
|
||||||
pollfd pollfds[1];
|
pollfd pollfds[1];
|
||||||
|
@ -243,12 +246,15 @@ int run(char **uris, int n)
|
||||||
std::vector<Request> reqvec;
|
std::vector<Request> reqvec;
|
||||||
std::string prev_host;
|
std::string prev_host;
|
||||||
uint16_t prev_port = 0;
|
uint16_t prev_port = 0;
|
||||||
|
int failures = 0;
|
||||||
for(int i = 0; i < n; ++i) {
|
for(int i = 0; i < n; ++i) {
|
||||||
uri::UriStruct us;
|
uri::UriStruct us;
|
||||||
if(uri::parse(us, uris[i])) {
|
if(uri::parse(us, uris[i])) {
|
||||||
if(prev_host != us.host || prev_port != us.port) {
|
if(prev_host != us.host || prev_port != us.port) {
|
||||||
if(!reqvec.empty()) {
|
if(!reqvec.empty()) {
|
||||||
communicate(prev_host, prev_port, reqvec, &callbacks);
|
if (communicate(prev_host, prev_port, reqvec, &callbacks) != 0) {
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
reqvec.clear();
|
reqvec.clear();
|
||||||
}
|
}
|
||||||
prev_host = us.host;
|
prev_host = us.host;
|
||||||
|
@ -258,9 +264,11 @@ int run(char **uris, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!reqvec.empty()) {
|
if(!reqvec.empty()) {
|
||||||
communicate(prev_host, prev_port, reqvec, &callbacks);
|
if (communicate(prev_host, prev_port, reqvec, &callbacks) != 0) {
|
||||||
|
++failures;
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
return failures;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_usage(std::ostream& out)
|
void print_usage(std::ostream& out)
|
||||||
|
@ -330,8 +338,7 @@ int main(int argc, char **argv)
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
reset_timer();
|
reset_timer();
|
||||||
run(argv+optind, argc-optind);
|
return run(argv+optind, argc-optind);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace spdylay
|
} // namespace spdylay
|
||||||
|
|
|
@ -76,6 +76,13 @@ class EndToEndSpdy2Tests(EndToEndSpdyTests):
|
||||||
self.assertEquals(0, self.call('/', ['-v', '-3']))
|
self.assertEquals(0, self.call('/', ['-v', '-3']))
|
||||||
self.assertIn('NPN selected the protocol: spdy/3', self.stdout)
|
self.assertIn('NPN selected the protocol: spdy/3', self.stdout)
|
||||||
|
|
||||||
|
def testFailedRequests(self):
|
||||||
|
self.assertEquals(
|
||||||
|
2, self.call('/', ['https://localhost:25/', 'http://localhost:79']))
|
||||||
|
|
||||||
|
def testOneFailedRequest(self):
|
||||||
|
self.assertEquals(1, subprocess.call([self.client, 'http://localhost:2/']))
|
||||||
|
|
||||||
|
|
||||||
class EndToEndSpdy3Tests(EndToEndSpdyTests):
|
class EndToEndSpdy3Tests(EndToEndSpdyTests):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue