Prechádzať zdrojové kódy

Adds getMethod for CivetServer

Thiago Macedo 4 rokov pred
rodič
commit
5aae63e27d
2 zmenil súbory, kde vykonal 15 pridanie a 0 odobranie
  1. 7 0
      include/CivetServer.h
  2. 8 0
      src/CivetServer.cpp

+ 7 - 0
include/CivetServer.h

@@ -488,6 +488,13 @@ class CIVETWEB_CXX_API CivetServer
 	                             const std::string &headerName);
 
 	/**
+	 * getMethod(struct mg_connection *conn)
+	 * @param conn - the connection information
+	 * @returns method of HTTP request
+	 */
+	static const char *getMethod(struct mg_connection *conn);
+
+	/**
 	 * getParam(struct mg_connection *conn, const char *, std::string &, size_t)
 	 *
 	 * Returns a query which contained in the supplied buffer.  The

+ 8 - 0
src/CivetServer.cpp

@@ -545,6 +545,14 @@ CivetServer::getHeader(struct mg_connection *conn,
 	return mg_get_header(conn, headerName.c_str());
 }
 
+const char *
+CivetServer::getMethod(struct mg_connection *conn)
+{
+	const struct mg_request_info *request_info = mg_get_request_info(conn);
+	assert(request_info != NULL);
+	return request_info->request_method;
+}
+
 void
 CivetServer::urlDecode(const char *src,
                        std::string &dst,