Forráskód Böngészése

Adds getMethod for CivetServer

Thiago Macedo 4 éve
szülő
commit
5aae63e27d
2 módosított fájl, 15 hozzáadás és 0 törlés
  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);
 	                             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)
 	 * getParam(struct mg_connection *conn, const char *, std::string &, size_t)
 	 *
 	 *
 	 * Returns a query which contained in the supplied buffer.  The
 	 * 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());
 	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
 void
 CivetServer::urlDecode(const char *src,
 CivetServer::urlDecode(const char *src,
                        std::string &dst,
                        std::string &dst,