diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-12 19:24:38 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-11-12 19:24:38 +0900 |
| commit | 0da2468d6b4ed4ef9f96cd3d50aa6e02da863da0 (patch) | |
| tree | 4790558d314e6ceb774a095e8144f20480017084 /src/HttpServer.cc | |
| parent | 2e5d9b056f2cf398d8996d93a4c7fbc1fbe66221 (diff) | |
Removed strappend
Diffstat (limited to 'src/HttpServer.cc')
| -rw-r--r-- | src/HttpServer.cc | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 3247457c..a30cc9ae 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -173,21 +173,26 @@ void HttpServer::feedResponse(const std::string& status, const std::string& contentType) { std::string httpDate = Time().toHTTPDate(); - std::string header = "HTTP/1.1 "; - strappend(header, status, "\r\n", - "Date: ", httpDate, "\r\n", - "Content-Type: ", contentType, "\r\n"); - strappend(header, "Content-Length: ", util::uitos(text.size()), "\r\n", - "Expires: ", httpDate, "\r\n", - "Cache-Control: no-cache\r\n"); + std::string header= fmt("HTTP/1.1 %s\r\n" + "Date: %s\r\n" + "Content-Type: %s\r\n" + "Content-Length: %lu\r\n" + "Expires: %s\r\n" + "Cache-Control: no-cache\r\n" + "%s%s", + status.c_str(), + httpDate.c_str(), + contentType.c_str(), + static_cast<unsigned long>(text.size()), + httpDate.c_str(), + supportsGZip() ? + "Content-Encoding: gzip\r\n" : "", + !supportsPersistentConnection() ? + "Connection: close\r\n" : ""); if(!allowOrigin_.empty()) { - strappend(header, "Access-Control-Allow-Origin: ", allowOrigin_, "\r\n"); - } - if(supportsGZip()) { - header += "Content-Encoding: gzip\r\n"; - } - if(!supportsPersistentConnection()) { - header += "Connection: close\r\n"; + header += "Access-Control-Allow-Origin: "; + header += allowOrigin_; + header += "\r\n"; } if(!headers.empty()) { header += headers; |
