From f7d1ca2740b36d91ec257e1d43e64092242246b5 Mon Sep 17 00:00:00 2001 From: Jim Morrison Date: Thu, 5 Apr 2012 11:11:02 -0700 Subject: [PATCH] Move timeout checking into the query parameter condition. Copy last_modified date string for file responses. --- examples/SpdyServer.cc | 12 ++++++++---- tests/end_to_end.py | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/SpdyServer.cc b/examples/SpdyServer.cc index 4946b611..fe113b42 100644 --- a/examples/SpdyServer.cc +++ b/examples/SpdyServer.cc @@ -272,6 +272,7 @@ int SpdyEventHandler::submit_file_response(const std::string& status, { std::string date_str = util::http_date(time(0)); std::string content_length = util::to_str(file_length); + std::string last_modified_str; const char *nv[] = { ":status", status.c_str(), ":version", "HTTP/1.1", @@ -283,8 +284,9 @@ int SpdyEventHandler::submit_file_response(const std::string& status, 0 }; if(last_modified != 0) { + last_modified_str = util::http_date(last_modified); nv[12] = "last-modified"; - nv[13] = util::http_date(last_modified).c_str(); + nv[13] = last_modified_str.c_str(); } return spdylay_submit_response(session_, stream_id, nv, data_prd); } @@ -460,9 +462,6 @@ void prepare_response(Request *req, SpdyEventHandler *hd) const std::string &field = req->headers[i].first; const std::string &value = req->headers[i].second; if(!url_found && field == ":path") { - // Do not response to this request to allow clients to test timeouts. - if (value.find("?spdyd_do_not_respond_to_req=yes") != std::string::npos) - return; url_found = true; url = value; } else if(field == ":method") { @@ -485,6 +484,11 @@ void prepare_response(Request *req, SpdyEventHandler *hd) } std::string::size_type query_pos = url.find("?"); if(query_pos != std::string::npos) { + // Do not response to this request to allow clients to test timeouts. + if (url.find("spdyd_do_not_respond_to_req=yes", + query_pos) != std::string::npos) { + return; + } url = url.substr(0, query_pos); } url = util::percentDecode(url.begin(), url.end()); diff --git a/tests/end_to_end.py b/tests/end_to_end.py index 98fad796..81a64b2a 100755 --- a/tests/end_to_end.py +++ b/tests/end_to_end.py @@ -86,6 +86,7 @@ class EndToEndSpdy2Tests(EndToEndSpdyTests): def testOneTimedOutRequest(self): self.assertEquals(1, self.call('/?spdyd_do_not_respond_to_req=yes', ['--timeout=2'])) + self.assertEquals(0, self.call('/', ['--timeout=20'])) class EndToEndSpdy3Tests(EndToEndSpdyTests):