diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-23 23:31:07 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-23 23:31:07 +0900 |
| commit | fba7e7ee8b8339c9709c1fe9d07279df07781af3 (patch) | |
| tree | 90c2fbbfbd056ec97890e27ae43e3ab533c010aa /src/HttpServer.cc | |
| parent | 508109edbb2ad74321ebdcf96989f18bc16271ba (diff) | |
Use move to send string data into SocketBuffer::pushStr
Diffstat (limited to 'src/HttpServer.cc')
| -rw-r--r-- | src/HttpServer.cc | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/HttpServer.cc b/src/HttpServer.cc index f314ee1e..bdfc093c 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -210,26 +210,27 @@ const std::string& HttpServer::getRequestPath() const return lastRequestHeader_->getRequestPath(); } -void HttpServer::feedResponse(std::string& text, const std::string& contentType) +void HttpServer::feedResponse(std::string text, + const std::string& contentType) { - feedResponse(200, "", text, contentType); + feedResponse(200, "", std::move(text), contentType); } void HttpServer::feedResponse(int status, const std::string& headers, - const std::string& text, + std::string text, const std::string& contentType) { std::string httpDate = Time().toHTTPDate(); - std::string header= fmt("HTTP/1.1 %s\r\n" - "Date: %s\r\n" - "Content-Length: %lu\r\n" - "Expires: %s\r\n" - "Cache-Control: no-cache\r\n", - getStatusString(status), - httpDate.c_str(), - static_cast<unsigned long>(text.size()), - httpDate.c_str()); + std::string header = fmt("HTTP/1.1 %s\r\n" + "Date: %s\r\n" + "Content-Length: %lu\r\n" + "Expires: %s\r\n" + "Cache-Control: no-cache\r\n", + getStatusString(status), + httpDate.c_str(), + static_cast<unsigned long>(text.size()), + httpDate.c_str()); if(!contentType.empty()) { header += "Content-Type: "; header += contentType; @@ -249,8 +250,8 @@ void HttpServer::feedResponse(int status, header += headers; header += "\r\n"; A2_LOG_DEBUG(fmt("HTTP Server sends response:\n%s", header.c_str())); - socketBuffer_.pushStr(header); - socketBuffer_.pushStr(text); + socketBuffer_.pushStr(std::move(header)); + socketBuffer_.pushStr(std::move(text)); } void HttpServer::feedUpgradeResponse(const std::string& protocol, @@ -264,7 +265,7 @@ void HttpServer::feedUpgradeResponse(const std::string& protocol, protocol.c_str(), headers.c_str()); A2_LOG_DEBUG(fmt("HTTP Server sends upgrade response:\n%s", header.c_str())); - socketBuffer_.pushStr(header); + socketBuffer_.pushStr(std::move(header)); } ssize_t HttpServer::sendResponse() |
