Add some comments

This commit is contained in:
antao 2018-12-25 18:23:33 +08:00
parent fd4b414a17
commit 47eee286c2

View File

@ -35,7 +35,7 @@ enum HttpMethod
Invalid
};
/// Abstract class for webapp developer to get Http client request;
/// Abstract class for webapp developer to get or set the Http request;
class HttpRequest
{
public:
@ -45,28 +45,73 @@ class HttpRequest
kHttp10 = 1,
kHttp11 = 2
};
/// Returns the method string of the request, such as GET, POST, etc.
virtual const char *methodString() const = 0;
virtual HttpMethod method() const = 0;
virtual std::string getHeader(const std::string &field) const = 0;
virtual std::string getCookie(const std::string &field) const = 0;
virtual const std::map<std::string, std::string> &headers() const = 0;
virtual const std::map<std::string, std::string> &cookies() const = 0;
virtual const std::string &query() const = 0;
virtual const std::string &path() const = 0;
virtual Version getVersion() const = 0;
virtual SessionPtr session() const = 0;
virtual const std::map<std::string, std::string> &getParameters() const = 0;
virtual const trantor::InetAddress &peerAddr() const = 0;
virtual const trantor::InetAddress &localAddr() const = 0;
virtual const trantor::Date &receiveDate() const = 0;
virtual ~HttpRequest() {}
virtual const std::shared_ptr<Json::Value> getJsonObject() const = 0;
/// Return the enum type method of the request.
virtual HttpMethod method() const = 0;
/// Get the header string identified by the @param field
virtual std::string getHeader(const std::string &field) const = 0;
/// Get the cookie string identified by the @param field
virtual std::string getCookie(const std::string &field) const = 0;
/// Get all headers of the request
virtual const std::map<std::string, std::string> &headers() const = 0;
/// Get all cookies of the request
virtual const std::map<std::string, std::string> &cookies() const = 0;
/// Get the query string of the request.
/**
* If the http method is GET, the query string is the substring after the '?' in the URL string.
* If the http method is POST, the query string is the content string of the HTTP request.
*/
virtual const std::string &query() const = 0;
/// Get the path of the request.
virtual const std::string &path() const = 0;
/// Return the enum type version of the request.
/**
* kHttp10 means Http version is 1.0
* kHttp11 means Http verison is 1.1
*/
virtual Version getVersion() const = 0;
/// Get the session to which the request belongs.
virtual SessionPtr session() const = 0;
/// Get parameters of the request.
virtual const std::map<std::string, std::string> &getParameters() const = 0;
/// Return the remote IP address and port
virtual const trantor::InetAddress &peerAddr() const = 0;
/// Return the local IP address and port
virtual const trantor::InetAddress &localAddr() const = 0;
/// Returns the receive timestamp set by the framework.
virtual const trantor::Date &receiveDate() const = 0;
/// Get the Json object of the request
virtual const std::shared_ptr<Json::Value> getJsonObject() const = 0;
/// Set the Http method
virtual void setMethod(const HttpMethod method) = 0;
/// Set the path of the request
virtual void setPath(const std::string &path) = 0;
/// Set the parameter of the request
virtual void setParameter(const std::string &key, const std::string &value) = 0;
/// Create a request object.
static HttpRequestPtr newHttpRequest();
virtual ~HttpRequest() {}
};
} // namespace drogon