void HttpServlet::DoPut(HttpServletRequest& request, HttpServletResponse& response) { std::string protocol = request.GetProtocol(); std::string msg = "Http PUT method not supported"; if (protocol.size() > 2 && protocol.substr(protocol.size()-3) == "1.1") { response.SendError(HttpServletResponse::SC_METHOD_NOT_ALLOWED, msg); } else { response.SendError(HttpServletResponse::SC_BAD_REQUEST, msg); } }
void HttpServlet::DoTrace(HttpServletRequest& request, HttpServletResponse& response) { std::string CRLF = "\r\n"; std::string responseString = "TRACE " + request.GetRequestUri() + " " + request.GetProtocol(); std::vector<std::string> reqHeaders = request.GetHeaderNames(); for (std::size_t i = 0; i < reqHeaders.size(); ++i) { responseString += CRLF + reqHeaders[i] + ": " + request.GetHeader(reqHeaders[i]); } responseString += CRLF; response.SetContentType("message/http"); response.SetContentLength(responseString.size()); response.GetOutputStream() << responseString << std::flush; return; }