From d72425de59db7d94dd51cca7988c3d025426925b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 31 Jul 2015 06:40:09 +0000 Subject: Add utility methods to HTTPRequest and HTTPResponse classes. Allow getting method name of an HTTPRequest, and connection open/closed status of an HTTPResponse. --- lib/httpserver/HTTPRequest.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/httpserver/HTTPRequest.cpp') 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(); + }; +} // -------------------------------------------------------------------------- // -- cgit v1.2.3