Move timeout checking into the query parameter condition. Copy last_modified date string for file responses.

This commit is contained in:
Jim Morrison 2012-04-05 11:11:02 -07:00
parent 9f8a988370
commit f7d1ca2740
2 changed files with 9 additions and 4 deletions

View File

@ -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());

View File

@ -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):