summaryrefslogtreecommitdiff
path: root/lib/httpserver/HTTPRequest.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-07-31 06:40:09 +0000
committerChris Wilson <chris+github@qwirx.com>2015-07-31 06:40:09 +0000
commitd72425de59db7d94dd51cca7988c3d025426925b (patch)
tree2545bc5321aedcfd962422277697e39f1f552ecc /lib/httpserver/HTTPRequest.cpp
parent762af2a462607258817fde3dc919ee7db5d1bcf0 (diff)
Add utility methods to HTTPRequest and HTTPResponse classes.
Allow getting method name of an HTTPRequest, and connection open/closed status of an HTTPResponse.
Diffstat (limited to 'lib/httpserver/HTTPRequest.cpp')
-rw-r--r--lib/httpserver/HTTPRequest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/httpserver/HTTPRequest.cpp b/lib/httpserver/HTTPRequest.cpp
index 4c5dc149..106bc30a 100644
--- a/lib/httpserver/HTTPRequest.cpp
+++ b/lib/httpserver/HTTPRequest.cpp
@@ -94,6 +94,32 @@ HTTPRequest::~HTTPRequest()
}
}
+// --------------------------------------------------------------------------
+//
+// Function
+// Name: HTTPRequest::GetMethodName()
+// Purpose: Returns the name of the request's HTTP method verb
+// as a string.
+// Created: 28/7/15
+//
+// --------------------------------------------------------------------------
+
+std::string HTTPRequest::GetMethodName() const
+{
+ switch(mMethod)
+ {
+ case Method_UNINITIALISED: return "uninitialised";
+ case Method_UNKNOWN: return "unknown";
+ case Method_GET: return "GET";
+ case Method_HEAD: return "HEAD";
+ case Method_POST: return "POST";
+ case Method_PUT: return "PUT";
+ default:
+ std::ostringstream oss;
+ oss << "unknown-" << mMethod;
+ return oss.str();
+ };
+}
// --------------------------------------------------------------------------
//