Jelajahi Sumber

Wrapper funtion for mg_het_header()

HariKamath 12 tahun lalu
induk
melakukan
f16f053e11
2 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 8 1
      include/CivetServer.h
  2. 5 0
      src/CivetServer.cpp

+ 8 - 1
include/CivetServer.h

@@ -153,7 +153,7 @@ public:
     CivetHandler *getHandler(const char *uri, unsigned urilen) const;
 	
 	/**
-	 * getCookie(const std::string &cookieName, std::string &cookieValue)
+	 * getCookie(struct mg_connection *conn, const std::string &cookieName, std::string &cookieValue)
 	 * @param conn - the connection information 
 	 * @param cookieName - cookie name to get the value from
 	 * @param cookieValue - cookie value is returned using thiis reference
@@ -162,6 +162,13 @@ public:
 	*/
 	int getCookie(struct mg_connection *conn, const std::string &cookieName, std::string &cookieValue);
 
+	/**
+	 * getHeader(struct mg_connection *conn, const std::string &headerName)
+	 * @param conn - the connection information 
+	 * @param headerName - header name to get the value from
+	 * @returns a char array whcih contains the header value as string
+	*/
+	const char* getHeader(struct mg_connection *conn, const std::string &headerName);
 protected:
 
     /**

+ 5 - 0
src/CivetServer.cpp

@@ -163,4 +163,9 @@ int CivetServer::getCookie(struct mg_connection *conn, const std::string &cookie
 	cookieValue.clear();
 	cookieValue.append(_cookieValue);
 	return lRead;
+}
+
+const char* CivetServer::getHeader(struct mg_connection *conn, const std::string &headerName)
+{
+	return mg_get_header(conn, headerName.c_str());
 }