From 541b6e9bce6d57649b3b5ad2f305319b6c26a449 Mon Sep 17 00:00:00 2001 From: Jim Morrison Date: Fri, 2 Mar 2012 14:30:35 -0800 Subject: [PATCH] Ensure that date and content length strings are still valid when they are put into the name values list. --- examples/SpdyServer.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/SpdyServer.cc b/examples/SpdyServer.cc index 4e5557f..40daca1 100644 --- a/examples/SpdyServer.cc +++ b/examples/SpdyServer.cc @@ -263,13 +263,15 @@ int SpdyEventHandler::submit_file_response(const std::string& status, off_t file_length, spdylay_data_provider *data_prd) { + std::string date_str = util::http_date(time(0)); + std::string content_length = util::to_str(file_length); const char *nv[] = { get_header_field(version_, HD_STATUS).c_str(), status.c_str(), get_header_field(version_, HD_VERSION).c_str(), "HTTP/1.1", "server", SPDYD_SERVER.c_str(), - "content-length", util::to_str(file_length).c_str(), + "content-length", content_length.c_str(), "cache-control", "max-age=3600", - "date", util::http_date(time(0)).c_str(), + "date", date_str.c_str(), 0, 0, 0 }; @@ -286,6 +288,7 @@ int SpdyEventHandler::submit_response const std::vector >& headers, spdylay_data_provider *data_prd) { + std::string date_str = util::http_date(time(0)); const char **nv = new const char*[8+headers.size()*2+1]; nv[0] = get_header_field(version_, HD_STATUS).c_str(); nv[1] = status.c_str(); @@ -294,7 +297,7 @@ int SpdyEventHandler::submit_response nv[4] = "server"; nv[5] = SPDYD_SERVER.c_str(); nv[6] = "date"; - nv[7] = util::http_date(time(0)).c_str(); + nv[7] = date_str.c_str(); for(int i = 0; i < (int)headers.size(); ++i) { nv[8+i*2] = headers[i].first.c_str(); nv[8+i*2+1] = headers[i].second.c_str();