diff --git a/lib/http_parser.cpp b/lib/http_parser.cpp index c0838dcf..a4f233d6 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -92,6 +92,17 @@ std::string & HTTP::Parser::BuildResponse(std::string code, std::string message) return builder; } +/// Returns a string containing a valid HTTP 1.0 or 1.1 response, ready for sending. +/// The response is partly build from internal variables set before this call is made. +/// To be precise, protocol, headers and body are used. +/// \param code The HTTP response code. Usually you want 200. +/// \param message The HTTP response message. Usually you want "OK". +/// \return A string containing a valid HTTP 1.0 or 1.1 response, ready for sending. +/// This function calls this->BuildResponse(this->method,this->url) +std::string & HTTP::Parser::BuildResponse() { + return BuildResponse(method,url); +} + /// Creates and sends a valid HTTP 1.0 or 1.1 response. /// The response is partly build from internal variables set before this call is made. /// To be precise, protocol, headers and body are used. diff --git a/lib/http_parser.h b/lib/http_parser.h index 4ba5ad97..84bdf20c 100644 --- a/lib/http_parser.h +++ b/lib/http_parser.h @@ -25,6 +25,7 @@ namespace HTTP { void SetBody(std::string s); void SetBody(char * buffer, int len); std::string & BuildRequest(); + std::string & BuildResponse(); std::string & BuildResponse(std::string code, std::string message); void SendRequest(Socket::Connection & conn); void SendResponse(std::string code, std::string message, Socket::Connection & conn);